Reputation: 313
On Linux g++/clang++
void test10058l(void*(*)(void*),void*(*)(const void*),const void*(*)(void*));
is mangled as _Z10test10058lPFPvS_EPFS_PKvEPFS3_S_E
S_
, S0_
, S1_
, ...)S3_
?(edit - adding some context)
The D language allows to interact with C++ by declaring symbols as extern(C++)
.
Unfortunately the current implementation is not always correct - I'm trying to fix it by implementing the current g++/clang++ name mangling scheme as defined by the Itanium C++ ABI.
Since this documentation is not crystal clear, I'm having a hard time understanding what accounts as a symbol.
Upvotes: 2
Views: 315
Reputation: 313
After several experiments I managed to understand how symbols are substituted. In particular, qualified types create new symbols and function account for symbols by themselves. A pointer to a function is then another symbol.
Here is the breakdown of the substitutions for the example I provided.
void test10058l(void*(*)(void*),void*(*)(const void*),const void*(*)(void*));
_Z10test10058lPFPvS_EPFS_PKvEPFS3_S_E
S_ ^^ : Pv void*
S0_ ^^^^^^ : FPvS_E void*()(void*)
S1_ ^^^^^^^ : PFPvS_E void*(*)(void*)
S2_ ^^ : Kv const void
S3_ ^^^ : PKv const void*
S4_ ^^^^^^^ : FS_PKvE void*()(const void*)
S5_ ^^^^^^^^ : PFS_PKvE void*(*)(const void*)
S6_ ^^^^^^^ : FS3_S_E const void*()(void*)
S7_ ^^^^^^^^ : PFS3_S_E const void*(*)(void*)
I started this git repository to report my findings regarding linux/osx GCC C++ name mangling.
Upvotes: 3
Reputation: 15824
Function mangling is compiler dependent activity, there is no standard direction for that. You can use following tool to demangle http://demangler.com/
Upvotes: 0