[Mono-list] Running vs2005 beta 2 compiled code on mono...

Kornél Pál kornelpal at hotmail.com
Fri Jul 1 20:43:48 EDT 2005

> Unfortunately /clr:safe just isn't a viable option.  You can't use any
> native datatypes if you have this switch on.  You can't do: struct foo {
> int bar, baz; };

The new managed C++ syntax is a bit different than the old syntax but is
more reliable.

ref struct foo {
int bar, baz; };

value struct foo {
int bar, baz; };

You can use ref class and value class as well. IL does not have separate
class and struct types so you can use any of the struct or class keyword
they mean the same.

ref creates an object reference while value creates a value class.

And you should look at the documentation of C++ language in MSDN to can use
understand these new features:

> We currently compile our low-level c++ libraries natively and we need to
> continue to be able to do that.
> To build our new software, ideally we could use our low-level libs in
> the mid-level code by just compiling it all to IL (using /clr:pure).
> This way the mid-level code could build .net objects for itself and the
> higher-level stuff to use.  Then (ideally) we could run everywhere with
> the same code (and possibly one build!) using mono.
> Since this now seems impossible, I'm looking at other options:
> I don't think we can use whidbey-style c++ interop because the only
> c++/cli compiler is in visual studio.  P/Invoke seems bad because our
> low-level libs are heavily object oriented c++ and P/Invoke seems to
> only work well for c-style interfaces.
> I'm struggling to figure out how to best do this sort of thing.

Native C++ libraries built for Win32 cannot be used on Mac anyway. So you
have to compile them into IL or use a native Mac library that is called by
the managed code using P/Invoke.

Alternatively you can embed Mono into your application and in this case you
can add InternalCalls that are managed methods but are implemented natively:


More information about the Mono-list mailing list