-
Wierd dll function names
I'm trying to make a WIN32 dll but I doesn't compile right somehow. For example:
Code:
__declspec(dllexport) int testfun(int x)
{
return x+1;
}
It compiles ok, but when i try to use testfun() from another program I get an error saying that that function doesn't exist in dll. I opened mydll.dll in DLL Viewer and it showed that that
function exists and is called "?testfun@@YAHH@Z". So, I tried using ?testfun@@YAHH@Z() in my program and it works! But how can I make a dll that has a correct function name? I'm using Visual Studio .NET 2003.
-
you need to use "C" linkage to avoind C++ name mangling
See here - http://cboard.cprogramming.com/showt...ight=dllexport
-
Ok, that works fine for functions. But, how do I declare/define classes so they have proper names?
-
Have a read through this http://www.codeguru.com/Cpp/Cpp/cpp_...cle.php/c4017/
I personally dont like exporting classes. If I want to encapsulate an object in a dll I like to use COM