Re: extern "C" ... again
- From: Victor Bazarov <v.Abazarov@xxxxxxxxxxxx>
- Date: Thu, 24 Jul 2008 09:17:23 -0400
Pelle wrote:
[..] if there is no rule to old-style C name mangling, how is the
linker to find the referred function? Imagine I use a 3rd party
library which has been built with a different compiler/linker, is it
still enough to specify <extern "C"> when using this library?
Name mangling follows a convention. The names are not random, there is some logic to it, do you agree? It's not impossible to imagine that the convention can be put in writing by the compiler developer and shared with other developers, yes? Let's take an opposite and imagine what would happen if it were true. What if car manufacturers instead of using the same 12 volts for their electrical systems would each use something different, 10 volts for one, 16 volts for another, 13.33 volts for the third and so on? Doesn't make sense, does it?
On the same operating system the software developers follow the recommendations of the OS developers when it comes to establishing their conventions. Take dynamic libraries for example. Windows is based on those. Functions in them have to have at least the ordinal number to be accessible from outside. Next, take static libraries. Development of stand-alone executables can be done without them, but why would anyone want to go to so much trouble? So, the OS manufacturer supplies at least the libraries to interface with the OS functionality. Now, if the compiler/linker is capable of using those libraries, why not make those requirements a convention and let any library to be usable in the same way?
Example: Intel C/C++ compiler follows Microsoft's convention for name mangling, so the object modules it produces are fully compatible with what Microsoft C/C++ compiler expects (and vice versa).
Not sure if this answers your question. If not, ask more question, I guess.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.
- Follow-Ups:
- Re: extern "C" ... again
- From: Pelle
- Re: extern "C" ... again
- References:
- extern "C" ... again
- From: Pelle
- extern "C" ... again
- Prev by Date: Re: extern "C" ... again
- Next by Date: Re: extern "C" ... again
- Previous by thread: Re: extern "C" ... again
- Next by thread: Re: extern "C" ... again
- Index(es):
Relevant Pages
|