[Mono-list] Questions on the Mono roadmap

Miguel de Icaza miguel@ximian.com
Tue, 18 Jan 2005 10:31:51 -0500


Hello,

> * Delegates with the attribute to specify that if they're
>   used to call native code, said code uses the C (cdecl) 
>   calling convention, rather than the Pascal (stdcall) 
>   calling convention that's the default for Microsoft C#.
>   The syntax goes thus:
> 
>     [UnmanagedFunctionPointerAttribute( CallingConvention.Cdecl)]
>     public delegate int TEST_callback_f_t(int a, int b);
> 
> * Marshal.GetDelegateForFunctionPointer(), which creates a
>   delegate that wraps a pointer to a native code function.

These seem relatively simple, and could be implemented.  

Please file a bug report in Bugzilla against these.

> * Managed C++ ;-) We will use this to create interfaces 
>   to .NET code that can be called by native C code. There 
>   doesn't seem to be an equivalent of C++ 'extern "C"' in 
>   C#, so we haven't found a way to create C-callable 
>   functions in C#. It seems very unlikely that we'd be 
>   able to take a Managed C++ DLL from Windows onto a Mono
>   platform and link C code against it successfully, so we 
>   need a way to build Managed C++ code on the Mono platform 
>   - or some other language that can provide C-callable 
>   interfaces and call C# code.

There is no solution at this point. 

One possibility is to add support for the runtime consumed by the new
"pure" CLI C++ code, but at this point we have not looked into what it
would take, nor how complete the support could be.

Even if we were able to run pure C++/CLI code, the problem is that this
code will likely depend on the internal structure of the vtables and
classes specific to the MS C++ compiler on Windows.  It will very likely
be different than the GCC produced output (in GCC this has changed
across versions for example).

My suggestion is to manually wrap the API entry points from C++ that you
need to consume, something like this:

#include "greeter.hpp"
extern "C" { int SayHello (void *object, char *person); }

int SayHello (void *object, char *person)
{
	((Greeter) object)->Hello (person);
}


> * Support for calling 64-bit native code, on 64-bit Linux, 
>   Solaris, et al. 

Mono 1.2 will work at least on two 64-bit platforms: amd64 and Solaris
64 bits (Mono 1.1.3 already supports this).

Miguel