C++ function names quick question
C++ function names quick question
I know there is someplace where we can get how C++ functions names (__mainvPcj etc.....) are translated to object code.
I just can't find where (tried googling but I think I was not sure what to search for ).
Any links/docs would be appreciated. TIA
I just can't find where (tried googling but I think I was not sure what to search for ).
Any links/docs would be appreciated. TIA
Only Human
Re:C++ function names quick question
The name mangling convention differs from Compiler vendor to Compilervendor imho, but g++ uses this ABI.
Re:C++ function names quick question
Hmm... off-topic a bit, but I've noticed a few instances of people using "imho" where it makes no sense. It expands to "In My Honest/Humble Opinion" (the H changes depending who's writing it usually).
If I'm reading a post and I hit something like "The name mangling convention differs from Compiler vendor to Compiler vendor imho" my parser falls over and my reading just kinda stops while it recovers. That's not really something you can have an opinion about, it either does or it doesn't. Maybe you were thinking of something like IIRC (If I Recall Correctly) or AFAIK (As Far As I Know)?
Anyway, the longest post so far in this thread is off-topic, sorry
If I'm reading a post and I hit something like "The name mangling convention differs from Compiler vendor to Compiler vendor imho" my parser falls over and my reading just kinda stops while it recovers. That's not really something you can have an opinion about, it either does or it doesn't. Maybe you were thinking of something like IIRC (If I Recall Correctly) or AFAIK (As Far As I Know)?
Anyway, the longest post so far in this thread is off-topic, sorry
Re:C++ function names quick question
Sorry. Ab jetzt schreibe ich meine Beitr?ge in deutsch, aber ich glaub kaum das dein Parser damit fertig wirdbluecode wrote:The name mangling convention differs from Compiler vendor to Compilervendor afaik, but g++ uses this ABI.
Perhaps that's because if you translate "imho" into german it does make sense in that context, afaik
Re:C++ function names quick question
Lol, I'm sorry if it sounded like an attack on you, it honestly wasn't. And yes, I'm sure if you wrote in German my parser would fall over even faster ;D
btw, and sorry for going even further off topic, does the meaning of the translated imho change, or is it one of those subtle differences that are destined to cause confusion for the rest of time (or until we all speak Mandarin, whichever comes first)?
btw, and sorry for going even further off topic, does the meaning of the translated imho change, or is it one of those subtle differences that are destined to cause confusion for the rest of time (or until we all speak Mandarin, whichever comes first)?
Re:C++ function names quick question
nah, no need to be sorryKemp wrote:Lol, I'm sorry if it sounded like an attack on you.
Some friend of mine told me that opinion has a different conotation than the german word "die Meinung / das Erachten". In german you don't need an opinion on a topic to say "meiner Meinung nach / meines Erachtens" (german for imo), because if you can't have one, it just means "as far as I know". I wasn't aware of that difference, so thanks for mentioning, that it is wrongsubtle differences that are destined to cause confusion for the rest of time (or until we all speak Mandarin, whichever comes first)?
And now I'm again sorry... this time for hijacking the thread
Re:C++ function names quick question
Ah! name mangling, that was what I was looking for (I had forgotten the name since its over 2 years since I used it).bluecode wrote: The name mangling convention differs from Compiler vendor to Compilervendor imho, but g++ uses this ABI.
Only Human
Re:C++ function names quick question
Ok I had a look.
What I was wanting to do is interface some C++ and ASM code (using NASM).
However for NASM to know the C++ function name I have to use extern "C" { }. But using his means that I cannot use C++ feature such as overloaded functions.
This makes it tedious to interface ASM and C++ code or is there some other way around this?
What I was wanting to do is interface some C++ and ASM code (using NASM).
However for NASM to know the C++ function name I have to use extern "C" { }. But using his means that I cannot use C++ feature such as overloaded functions.
This makes it tedious to interface ASM and C++ code or is there some other way around this?
Only Human
Re:C++ function names quick question
Well, I never tried to interface C++ code from assembler, but if you compile your C++ code to some object format and than objdump on it (with all headers displayed) you can find out, which name your C++ Compiler gives your C++ functions. You just take that name (which might of course look very weird, because of the name mangling) and put "extern <yourc++functionname>" into nasm and call that function. But be aware of a different calling convention
Re:C++ function names quick question
You can use a wrapper function, with extern "C", and then call C++ linked code from that small wrapper. The wrapper itself can't be overloaded, but it's still compiled as C++, so it can call other overloaded functions or whatever you want.
Ofcourse you can also make a general wrapper and play with things like function pointers and the so-called visitor pattern if you feel like it.
I would avoid relying at name mangling at all cost. It seems that it gets changed every two years anyway.
Ofcourse you can also make a general wrapper and play with things like function pointers and the so-called visitor pattern if you feel like it.
I would avoid relying at name mangling at all cost. It seems that it gets changed every two years anyway.
Re:C++ function names quick question
Isn't there an option in most compilers (by which I mean VC++ and G++ ) to turn off name mangling?
Re:C++ function names quick question
Without name mangling there's no overloading, and without overloading there's really no C++.
Re:C++ function names quick question
Are there any plans to make the name mangling standard?
Only Human
Re:C++ function names quick question
The above mentioned ABI that G++ uses is one such attempt at a standard C++ ABI, including name mangling.
I would expect hell to melt before everyone uses it, though.
I would expect hell to melt before everyone uses it, though.