Question

I'm working on a shared C++ DLL using Netbeans and MinGW under Windows.

My first question is: will mangling be different between MinGW and Microsoft Visual C++? I read that mangling is compiler specific - is it true? I need to obtain using MinGW the same mangling which I would have with MVC++, will this ever be possibile?

I discovered, using Dependency Walker, that the functions which are exported are also seen as C (and they are not exported as C in my code). Does this depends on a limitation of DepWalker or for some reason MinGW is making my library exporting as C? (I verified that using "export C" I don't see mangling anymore, while without, I see name mangling (which is different from what I was expecting based on MVC++) but I still see the "C" icon instead of "C++".

Here's the linking command:

g++.exe -static-libgcc -static-libstdc++ -shared -o my.dll -s 1.o 2.o ... n.o other.dll -static

Thank in advance and best regards.

Was it helpful?

Solution

Yes, name mangling is compiler-specific. It could even change between versions of the same compiler.

You should never expect anything about mangling and should treat it as a black box - never rely on it to be the same or different.

If you need inter-compiler linkage use extern "C".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top