Is there anything to change the export name export scheme in GCC?

I am trying to create a project that I have and it has several exported functions. Functions follow the stdcall convention and they become crippled if compiled using GCC as

Func@X 

Other compilers change the name as follows:

 _Func@X 

Is there any way to make GCC affect the names of exported functions in a later example?

+7
c gcc name-mangling
source share
3 answers

See this answer .

 int Func() __asm__("_Func@X"); 

This will force GCC to call the _Func@X character no matter what it would normally do.


Oh right, @ is special: it is used to control character versions. I thought __asm__("...@...") used to working, but I think this is no more.

 int Func() __asm__("_Func"); __asm__(".symver _Func, _Func@X"); 

This should be followed by a version script file, for example:

 1 { global: _Func; }; 

specified by gcc -Wl,--version-script=foo.version when linking.

+4
source share

See the GCC manual for fleading-underscore . However, read the warnings about the consequences of this action; it may not be the solution you think so.

0
source share

The best bet when working with a function name in Windows is to always use a .def file. This will work regardless of the compiler. Usually you need the EXPORTS section:

 EXPORTS Func1 Func2 ... 
0
source share

All Articles