Function name commingle

Discussion in 'C++' started by David Alasiga, Mar 28, 2006.

  1. 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.
     
    David Alasiga, Mar 28, 2006
    #1
    1. Advertising

  2. On Tue, 28 Mar 2006 14:19:32 GMT, "David Alasiga"
    <> 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.
    >


    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.

    --
    Bob Hairgrove
     
    Bob Hairgrove, Mar 28, 2006
    #2
    1. Advertising

  3. David Alasiga

    Ben Pope Guest

    David Alasiga wrote:
    > 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'm not just a number. To many, I'm known as a string...
     
    Ben Pope, Mar 28, 2006
    #3
  4. "David Alasiga" <> 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
     
    Ivan Vecerina, Mar 28, 2006
    #4
  5. David Alasiga

    Pete Becker Guest

    Ivan Vecerina wrote:
    > "David Alasiga" <> 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.

    --

    Pete Becker
    Roundhouse Consulting, Ltd.
     
    Pete Becker, Mar 28, 2006
    #5
  6. "Pete Becker" <> wrote in message
    news:...
    : Ivan Vecerina wrote:
    : > "David Alasiga" <> 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:
    > 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
    --
    http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
     
    Ivan Vecerina, Mar 29, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?iso-8859-1?B?bW9vcJk=?=
    Replies:
    7
    Views:
    897
    Roedy Green
    Jan 2, 2006
  2. ding feng
    Replies:
    2
    Views:
    2,913
    ding feng
    Jun 25, 2003
  3. Bobby Chamness
    Replies:
    2
    Views:
    2,444
    Joe Smith
    Apr 22, 2007
  4. Jack-2
    Replies:
    3
    Views:
    334
    Jack-2
    Dec 24, 2003
  5. Java  script  Dude

    IE name="name" & form.name property bug

    Java script Dude, Jun 29, 2004, in forum: Javascript
    Replies:
    5
    Views:
    283
    Java script Dude
    Jun 30, 2004
Loading...

Share This Page