How to change the appearance of the exported name for __stdcall in VC ++?

Here's how I declared my export function at the moment:

extern "C" __declspec(dllexport) Iexport_class* __stdcall GetExported_Class(); 

When VS2008 compiled the source for this, the created dll contains this in its export table:

 _GetExported_Class@0 

For compatibility with other compilers, I need this decoration to look like this:

 GetExported_Class 

Changing the calling convention to __cdecl will decorate it the way I want, but the convention will be wrong, so I cannot use it. I need it to be styled as __cdecl looks, but uses __stdcall instead.

Is there a way to do this without using a .def file? Is there a switch or parameter that I can pass to the link.exe linker that can make it decorate the export name the way I want?

thanks

+4
source share
3 answers

No. All __stdcall names are styled this way. I am amazed that you have another compiler that does not expect the __stdcall export to be styled this way. Redefining the linker with .def is almost all you can do if you don't want to change the PE file after production.

+3
source

I do not understand why you do not want to use the .def file, but this is your only option.

The component supports the export switch, but it cannot be used with functions that __stdcall annotates:

http://msdn.microsoft.com/en-US/library/7k30y2k5.aspx

The def file method is almost the only solution.

+2
source

Yes:

You can add /EXPORT to the lib.exe command line or add #pragma to the source file:

 #pragma comment(linker, "/EXPORT: SomeFunction=_SomeFunction@ @@23mangledstuff#@@@@") 

Or even simpler: inside the function body use

 #pragma comment(linker, "/EXPORT:" __FUNCTION__ "=" __FUNCDNAME__) 

Source: fooobar.com/questions/204458 / ...

0
source

Source: https://habr.com/ru/post/1332885/


All Articles