I am trying to import a function from an unmanaged code c++ dll into my c# application. The c++ prototype is
int somefunction (int param1, int *param2 = NULL);
How do I declare this in c# to take advantage of the optional nature of param2? The following code does not work. param2 gets initialized with garbage.
DllImportAttribute("mydll.dll", EntryPoint = "somefunction")]
public static extern int somefunction(int param1);