Function name commingle

D

David Alasiga

Does g++ have option to disable function name commingle. When I compile
like:

g++ -S Test.cpp

the file Test.s has function name commingled. For example, function name
foo becomes like __foo79emskd8. Is there any options which output function
name as original instead of commingled name? Thanks in advance.
 
B

Bob Hairgrove

Does g++ have option to disable function name commingle. When I compile
like:

g++ -S Test.cpp

the file Test.s has function name commingled. For example, function name
foo becomes like __foo79emskd8. Is there any options which output function
name as original instead of commingled name? Thanks in advance.

Maybe the FAQ can help:
http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html

In general, you want to prefix the function with:
extern "C" void foo() // etc.

However, even with C functions, some compilers will prefix the
exported name with an underscore.
 
B

Ben Pope

David said:
Does g++ have option to disable function name commingle. When I compile
like:

I think you mean "name mangling".

Try asking in a g++ newsgroup.

Ben Pope
 
I

Ivan Vecerina

: Does g++ have option to disable function name commingle. When I compile
: like:
:
: g++ -S Test.cpp
:
: the file Test.s has function name commingled. For example, function
name
: foo becomes like __foo79emskd8. Is there any options which output
function
: name as original instead of commingled name? Thanks in advance.

Try including the declaration and definition of your function(s) in
an extern "C" block:
extern "C" {
void foo(int i);
}
This will disable the name-mangling of C++ for compatibility with C.

This is as far as you can get with portable C++.

Regards,
Ivan
 
P

Pete Becker

Ivan said:
: Does g++ have option to disable function name commingle. When I compile
: like:
:
: g++ -S Test.cpp
:
: the file Test.s has function name commingled. For example, function
name
: foo becomes like __foo79emskd8. Is there any options which output
function
: name as original instead of commingled name? Thanks in advance.

Try including the declaration and definition of your function(s) in
an extern "C" block:
extern "C" {
void foo(int i);
}
This will disable the name-mangling of C++ for compatibility with C.

But it won't do what he asked for, which is use the original function
name. It mangles the name by prepending an underscore.
 
I

Ivan Vecerina

: Ivan Vecerina wrote:
: > : > : Does g++ have option to disable function name commingle. When I
compile
: > : like:
: > :
: > : g++ -S Test.cpp
: > :
: > : the file Test.s has function name commingled. For example, function
: > name
: > : foo becomes like __foo79emskd8. Is there any options which output
: > function
: > : name as original instead of commingled name? Thanks in advance.
: >
: > Try including the declaration and definition of your function(s) in
: > an extern "C" block:
: > extern "C" {
: > void foo(int i);
: > }
: > This will disable the name-mangling of C++ for compatibility with C.
: >
:
: But it won't do what he asked for, which is use the original function
: name. It mangles the name by prepending an underscore.
It will on many platforms, although this detail is outside the
scope of the standard, right?

And as I indicated next in what you omitted to quote:
> This is as far as you can get with portable C++
inviting the OP to look for a platform-specific solution if
he needs to go "further" in removing any remaining decoration.

So, Pete, I'm not sure in what way your reply here was intended
to be informative. But in my opinion this is one of many posts of
yours that could have used being written in a less arrogant tone.

Sorry,
Ivan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top