[Mono-list] Mono embedding: invoke c code with char*
Robert Jordan
robertj at gmx.net
Wed Apr 9 05:08:03 EDT 2008
Ing. Francesco Carsana wrote:
> Hi,
>
> I'm working with mono embedding, and I'm trying
> to invoke a c function that accepts two
> parameters:
>
> [MethodImpl(MethodImplOptions.InternalCall)]
> private unsafe extern static void
> OnConnectHandler(char* _ipAddress, bool _connected);
>
> This function is invoked inside this method:
>
> private static void OnConnect(string _ip, bool _conn);
>
> The problem is: how can I convert string to char*?
> Is it possible to invoke mono_string_to_utf8?
>
> Thank You.
Why would you use the signature OnConnectHandler(char* _ipAddress, bool
_connected); for an internal call in the first place??
Declare it as OnConnectHandler(string, bool) and use MonoString*
for your C++ icall. There you can use mono_string_to_utf8.
Robert
More information about the Mono-list
mailing list