extern "C" not working?

Hello...

In dll
Header:
1
2
3
#define C_API extern "C" __declspec(dllexport)

C_API GameManager* APIENTRY CreateNewGame();


Cpp file:
1
2
3
4
C_API GameManager* APIENTRY CreateNewGame()
{
	return new GameManager();
};


dumpbin result
16    F 00011230 _CreateNewGame@0 = @ILT+555(_CreateNewGame@0)


what is wrong with my code? why C++ compiler miss up the name of my factory function even though I use extern "C"?

Info:
GameManager class implements interface GameManagerinterface
I can call the factory function if i used the name that results from dumpbin (decorated/mangled)
-----------------------------------------------------------------------------------------------
Edit: sorry I fixed name mangling by removing APIENTRY macro (__stdcall)(found a post on how WINAPI/APIENTRY force name mangling http://stackoverflow.com/questions/4172509/extern-c-not-working-as-expected)...

should i expect any problems or limitations without the WINAPI/APIENTERY (__stdcall)??
Last edited on
No, you should not expect anymore issues like this after removing APIENTRY. You've identified the issue correctly, that you were overriding the extern "C" command and reintroducing name mangling with this command. If possible avoid using any calling conventions that you can, or make an import library. After you get comfortable writing DLL files I highly recommend looking into import libraries since they would fix this issue and allow you to overload function names all in one shot.
thanks Computergeek01..
Topic archived. No new replies allowed.