I have standard ANSI C code that is authoritative. This means that although I have a source, I cannot translate into another language and not change the arguments of the call, since these actions will deprive the right. There are over 150 functions.
I can make random changes, for example, change the file names from .C to .CPP so that it compiles using the Visual Studio 2009 C ++ compiler that I made. Compiler directives can also be added, etc. I can also go through the shell layer if necessary.
Another limitation is that my company does not want me to use the unsafe keyword in any C # code.
I need to get these functions from a C # program.
A typical C / C ++ function is as follows:
double SomeFunction(double a, double[3] vec, double[3][3] mat);
Where the contents of the array are sometimes entered, sometimes, and, as a rule, both are displayed.
I first tried making an unmanaged DLL (with functions marked with Extern C). Functions with only simple arguments (int, double) worked fine, but I couldn't figure out how to marshal arrays. (In fact, I found some sample code, but it was extremely difficult and unreasonable to duplicate 150 times.)
Then I tried two projects in one solution, one in C ++ and the other in C #. In a C ++ project, I created a managed function that was just called the original function, which was marked as unmanaged. It was very clean and simple, and again simple arguments worked perfectly. But for arrays, I could not find a way to match argument types between C # and C ++ borders:
Argument '2': cannot convert from 'double[]' to 'double*'
(and, as mentioned above, I cannot use unsafe to get a pointer).
Of course, what I'm trying to do should be possible.
What is the best way to get these features?
(Sample code using the above function will be really cool.)