Why extern "C" still cannot remove name manipulation in the following case

extern "C" { __declspec(dllexport) LRESULT CALLBACK MTest } 

Usage is dependent, I found that there is still the name mangling even with extern "C" .

+4
source share
3 answers

The only way to get really unshared names using __declspec (dllexport) is to export them using the __cdecl calling convention. CALLBACK becomes __stdcall, which adorns the "C" form of the name with leading _ and trailing @bytes.

Otherwise, you can use the .DEF file, which is a pain. Another way for MSVC is to insert the / EXPORT directive in the object file (or pass it as an explicit linker setting)

 #pragma comment(linker, "/EXPORT:ExportSymbol=DecoratedName"); 

For some reason, part = directive is not listed in the help

+7
source

This is a decoration of the name, not a distortion. You must declare an undecorated name in the DEF file, and then you get the behavior you are looking for.

+4
source

Not being a great visual C ++ programmer, the first thought that comes up for me is ... "does any of these macros LRESULT or CALLBACK introduce a standard calling convention?" Do the changed names have @NUMBER_OF_BYTES_OF_PARAMATER_LIST or characters representing actual types added to them?

0
source

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


All Articles