I have a DLL containing C++ code, which works perfectly in Visual C#. When I create a fucton in the C++ DLL, it shows up in Visual C# and I call it, even with parameters. However, when I add a function pointer as one of the parameters in the C++ DLL, it cannot be found by Visual C#.
C++ Functions:
int TEST(int *func) // Works fine and shows up in visual C#.
{
return 0;
}
int TEST2(int (*func)()) // Works, however doesn't show up in Visual C#
{
return 0;
}
UPDATE:
When I call TEST2 from C#, I get the error: 'TEST2' is not supported by the language
函数指针参数应该像这样声明:
int TEST2(int (*func)()) { /*...*/ }
我很确定你需要围绕*func
括号来告诉编译器* func是一个指向函数int (*func)()
的指针,而不是你所拥有的int *(*func)()
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.