Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 28th, 2006, 02:35 PM
David Alasiga
Guest
 
Posts: n/a
Default Function name commingle

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.


  #2  
Old March 28th, 2006, 02:46 PM
Ben Pope
Guest
 
Posts: n/a
Default Re: Function name commingle

David Alasiga wrote:[color=blue]
> Does g++ have option to disable function name commingle. When I compile
> like:[/color]

I think you mean "name mangling".

Try asking in a g++ newsgroup.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
  #3  
Old March 28th, 2006, 02:46 PM
Ivan Vecerina
Guest
 
Posts: n/a
Default Re: Function name commingle

"David Alasiga" <dialectics@yahoo.com> wrote in message
news:UBbWf.1044$ui7.95@trndny09...
: 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
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com


  #4  
Old March 28th, 2006, 03:15 PM
Bob Hairgrove
Guest
 
Posts: n/a
Default Re: Function name commingle

On Tue, 28 Mar 2006 14:19:32 GMT, "David Alasiga"
<dialectics@yahoo.com> wrote:
[color=blue]
>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.
>[/color]

Maybe the FAQ can help:
http://www.parashift.com/c++-faq-lit...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.

--
Bob Hairgrove
NoSpamPlease@Home.com
  #5  
Old March 28th, 2006, 03:25 PM
Pete Becker
Guest
 
Posts: n/a
Default Re: Function name commingle

Ivan Vecerina wrote:[color=blue]
> "David Alasiga" <dialectics@yahoo.com> wrote in message
> news:UBbWf.1044$ui7.95@trndny09...
> : 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.
>[/color]

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

--

Pete Becker
Roundhouse Consulting, Ltd.
  #6  
Old March 29th, 2006, 06:55 AM
Ivan Vecerina
Guest
 
Posts: n/a
Default Re: Function name commingle

"Pete Becker" <petebecker@acm.org> wrote in message
news:qfKdnRWs-IDizLTZRVn-pg@giganews.com...
: Ivan Vecerina wrote:
: > "David Alasiga" <dialectics@yahoo.com> wrote in message
: > news:UBbWf.1044$ui7.95@trndny09...
: > : 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:[color=blue]
> This is as far as you can get with portable C++[/color]
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
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form


 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles