Re: Name decoration

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 08/17/04


Date: Tue, 17 Aug 2004 15:10:07 -0400

Michael Hoffmann wrote:
> [...] My linker works like this:
> All functions found in the OBJs are exported by the import libaries without
> the underscore being removed again.[...]

I have hard time understanding that sentence. "without the underscore
being removed again". So, is it being removed or not? Why "again"? When
was it already removed? Are the functions without the underscore or with
the underscore? When your compiler creates the code, couldn't it just add
underscores to the functions it knows come from the C side? Does it know
whether they are from the C side? If it can't resolve the symbol without
the underscore, could it simply add the underscore and try resolving it
again?

> Is there a reason why the _ is added?

I cannot recall seeing or hearing any particular reason except that at
some point it made a difference when linking Pascal (or FORTRAN) libraries
along with C libraries just to make sure that C functions were resolved
from the C object modules. So, the compiler always adds the underscores,
and there is no problem for any linker -- C code that needs a C function
also has the function's name prepended with an underscore, thus a match
can easily be made.

For linking with functions from other languages C (and C++) has the
'linkage specification' mechanism. Symmetrically, other languages _may_
have similar mechanisms for linking in C libraries.

Victor



Relevant Pages

  • RE: Cookies in IE 6 SP1
    ... I could resolve the problem. ... My url has an underscore and IE 6 SP1 doesn't show cookies if the Url has it symbol. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: good address will not resolve in freebsd
    ... > to resolve in freebsd. ... There's an underscore in the hostname, ...
    (freebsd-stable)
  • Re: good address will not resolve in freebsd
    ... There's an underscore in the hostname, ... That is kind of a bummer that it won't resolve. ... To unsubscribe, ...
    (freebsd-stable)
  • RE: Error 8007274D
    ... I've got a similar problem about the error code 8007274D: how to resolve it? ... Please help me and write to me to: scandal__@virgilio.it (double underscore). ... I'm waiting for yor answer. ...
    (microsoft.public.windowsmedia.player)
  • Re: Run-time linking frustration
    ... RP> I'm working on a largish software project whose libraries use run-time ... RP> (linking the executable with -Wl,-brtl,-bexpall,-bsymbolic, linking ... RP> deferred imports or several other load time related problems. ... RP> could not resolve some symbols. ...
    (comp.unix.aix)