[Mono-dev] internal call from c# to c++
Erik Christensen
ke at nowet.dk
Fri Aug 25 07:28:26 EDT 2006
Hi,
Trying to make a program, where it's possible to use C# to script to the
Core (C++ code).
I don't want to use P/Invoke.
I can run the Internal calls example from
http://http://www.mono-project.com/Embedding_Mono
http://www.mono-project.com/Embedding_Mono without a problem. And
everything's fine as long as the function(s) doesn't use any argument(s).
However, I just can't seem to get a hold of the arguments on the C++ side.
Can someone pass an advice on this please?
Testcode is:
**************
C# :
**************
using System;
using System.Runtime.CompilerServices;
class Test
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern private int calcsum(int a, int b);
static void Main(string[] args)
{
Test t = new Test();
Console.Write(t.calcsum(3,3));
}
}
**************
C++ : (mono embed)
**************
//include's
int calcsum(int a, int b)
{
return (a+b);
}
int main(int argc, char* argv[])
{
//...
mono_add_internal_call ("Test::calcsum(int,int)", calcsum);
//...
}
It'll compile, and run, however the result is just random numbers from
somewhere in the memory, which should mean that the "a" and "b" variables
aren't set from the c# side (ie. the 3 is lost somewhere).
Really hope anyone can enlighten me on this one.
Cheers!
--
View this message in context: http://www.nabble.com/internal-call-from-c--to-c%2B%2B-tf2164200.html#a5981690
Sent from the Mono - Dev forum at Nabble.com.
More information about the Mono-devel-list
mailing list