Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > C++

Reply
 
 
chambu
Guest
Posts: n/a
 
      02-23-2008
Hi,
can somebody explore me more on Concept of Name Mangling used by C+
+ compilers.Also what is is the concept of UNICODES & what are
TRIGRAPH SEQUENCES.

Regards,

Chambu
 
Reply With Quote
 
 
 
 
James Kanze
Guest
Posts: n/a
 
      02-23-2008
On Feb 23, 5:28 am, chambu <(E-Mail Removed)> wrote:

> can somebody explore me more on Concept of Name Mangling
> used by C++ compilers.


An implementation detail, which varies from one compiler to the
next.

> Also what is is the concept of UNICODES


www.unicode.org. Also the first five chapters of _Fontes_ _et_
_codages_, by Yannis Haralambous. (An English translation, and
probably others, is available.)

> & what are
> TRIGRAPH SEQUENCES.


Something you don't want to know about. A solution to a problem
that had ceased to exist by the time they were implemented.
(See http://www.gotw.ca/gotw/086.htm, for example.)

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
 
Reply With Quote
 
 
 
 
Juha Nieminen
Guest
Posts: n/a
 
      02-23-2008
James Kanze wrote:
>> can somebody explore me more on Concept of Name Mangling
>> used by C++ compilers.

>
> An implementation detail, which varies from one compiler to the
> next.


Which is a shame, really. It hinders C++'s capabilities at creating
shared and precompiled libraries. Either all C++ shared/precompiled
libraries and C++ programs in a system must be compiled with the same
compiler, or if several different compilers are used, they all must use
the exact same name mangling system which, as you say, is often not the
case.

If name mangling was standardized, it would greatly increase the
usability of C++ to create shared and precompiled libraries usable among
different compilers.

If I'm not mistaken, in the C world name mangling has been long ago
"standardized" (if not de jure, at least de facto), which is why C is so
much more usable for precompiled libraries: A library created by any C
compiler is usable by any another C (and even C++) compiler.
 
Reply With Quote
 
Rolf Magnus
Guest
Posts: n/a
 
      02-23-2008
Juha Nieminen wrote:

> James Kanze wrote:
>>> can somebody explore me more on Concept of Name Mangling
>>> used by C++ compilers.

>>
>> An implementation detail, which varies from one compiler to the
>> next.

>
> Which is a shame, really. It hinders C++'s capabilities at creating
> shared and precompiled libraries.


There are a lot more things to consider for that than just name mangling.

> Either all C++ shared/precompiled libraries and C++ programs in a system
> must be compiled with the same compiler, or if several different compilers
> are used, they all must use the exact same name mangling system which, as
> you say, is often not the case.
>
> If name mangling was standardized, it would greatly increase the
> usability of C++ to create shared and precompiled libraries usable among
> different compilers.
>
> If I'm not mistaken, in the C world name mangling has been long ago
> "standardized" (if not de jure, at least de facto),


Even though C wouldn't actually need any name mangling at all, it is in fact
not "standardized", at least not under all systems. I have found that out
lately when I needed to write a DLL for Windows that can be used as a
drop-in replacement for an old one.

 
Reply With Quote
 
Pete Becker
Guest
Posts: n/a
 
      02-23-2008
On 2008-02-23 07:14:51 -0500, Juha Nieminen <(E-Mail Removed)> said:

>
> If name mangling was standardized, it would greatly increase the
> usability of C++ to create shared and precompiled libraries usable among
> different compilers.
>


Name mangling is one of several problems in getting different compilers
to work together. You also need to agree on object layout, calling
conventions, and, perhaps, register usage. These are all platform
specific, so there's no universal solution that handles all of them.

> If I'm not mistaken, in the C world name mangling has been long ago
> "standardized" (if not de jure, at least de facto), which is why C is so
> much more usable for precompiled libraries: A library created by any C
> compiler is usable by any another C (and even C++) compiler.


Back when I was paying attention to it, many C compilers mangled names
by putting an underscore at the beginning of the name. Some put it at
the end. Some just used the name itself. And libraries created by any C
compiler could be used by any other C compiler only to the extent that
vendors agreed on name mangling, object layout, and calling conventions.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

 
Reply With Quote
 
Jeff Schwab
Guest
Posts: n/a
 
      02-23-2008
Rolf Magnus wrote:
> Juha Nieminen wrote:

....
>> If I'm not mistaken, in the C world name mangling has been long ago
>> "standardized" (if not de jure, at least de facto),

>
> Even though C wouldn't actually need any name mangling at all it is in fact
> not "standardized", at least not under all systems. I have found that out
> lately when I needed to write a DLL for Windows that can be used as a
> drop-in replacement for an old one.


What kind of mismatch did you see? I though each externally linked C
identifiers in Windows object files had exactly one leading underscore,
followed by the C identifier.
 
Reply With Quote
 
Rolf Magnus
Guest
Posts: n/a
 
      02-23-2008
Jeff Schwab wrote:

> Rolf Magnus wrote:
>> Juha Nieminen wrote:

> ...
>>> If I'm not mistaken, in the C world name mangling has been long ago
>>> "standardized" (if not de jure, at least de facto),

>>
>> Even though C wouldn't actually need any name mangling at all it is in
>> fact not "standardized", at least not under all systems. I have found
>> that out lately when I needed to write a DLL for Windows that can be used
>> as a drop-in replacement for an old one.

>
> What kind of mismatch did you see?


About what is described here: http://www.geocities.com/yongweiwu/stdcall.htm

> I though each externally linked C identifiers in Windows object files had
> exactly one leading underscore, followed by the C identifier.


It seems that this is the case only as long as you don't use dynamically
linked libraries, and even then you can't be sure of that, considering the
comment below the table on that web page.


 
Reply With Quote
 
Rolf Magnus
Guest
Posts: n/a
 
      02-23-2008
Pete Becker wrote:

> On 2008-02-23 07:14:51 -0500, Juha Nieminen <(E-Mail Removed)> said:
>
>>
>> If name mangling was standardized, it would greatly increase the
>> usability of C++ to create shared and precompiled libraries usable among
>> different compilers.
>>

>
> Name mangling is one of several problems in getting different compilers
> to work together. You also need to agree on object layout, calling
> conventions, and, perhaps, register usage.


Don't forget things like exception handling and details like dynamic
initialization of global objects or NRVO. And then, there is the standard
library. If name mangling is the same, you can't link standard libraries of
two different compilers together, but each compiler uses its own headers,
so I wouldn't expect code compiled to run with one standard library
implementation to work with another.

> These are all platform specific, so there's no universal solution that
> handles all of them.


I'd say most parts don't really need to be different for different
platforms. There even is a more-or-less-standard ABI, but there are just a
lot of compilers that don't support it.

 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      02-23-2008
Pete Becker wrote:
> On 2008-02-23 07:14:51 -0500, Juha Nieminen <(E-Mail Removed)> said:
>> If name mangling was standardized, it would greatly increase the
>> usability of C++ to create shared and precompiled libraries usable among
>> different compilers.

>
> Name mangling is one of several problems in getting different compilers
> to work together. You also need to agree on object layout, calling
> conventions, and, perhaps, register usage. These are all platform
> specific, so there's no universal solution that handles all of them.


Precompiled libraries are platform specific. That wasn't the point.

What I meant was that I can create a precompiled or even a dynamically
loadable shared library in C with gcc and use it in code I'm compiling
using icc (or basically any other C compiler for the same system).

C++ has this problem that a precompiled library created with one
compiler may not be usable with another. In some cases it might not even
be usable with the next version of the *same* compiler! This is because
compilers don't seem to yet agree on which name mangling convention to use.
 
Reply With Quote
 
Jeff Schwab
Guest
Posts: n/a
 
      02-23-2008
Rolf Magnus wrote:
> Jeff Schwab wrote:
>
>> Rolf Magnus wrote:
>>> Juha Nieminen wrote:

>> ...
>>>> If I'm not mistaken, in the C world name mangling has been long ago
>>>> "standardized" (if not de jure, at least de facto),
>>> Even though C wouldn't actually need any name mangling at all it is in
>>> fact not "standardized", at least not under all systems. I have found
>>> that out lately when I needed to write a DLL for Windows that can be used
>>> as a drop-in replacement for an old one.

>> What kind of mismatch did you see?

>
> About what is described here: http://www.geocities.com/yongweiwu/stdcall.htm
>
>> I though each externally linked C identifiers in Windows object files had
>> exactly one leading underscore, followed by the C identifier.

>
> It seems that this is the case only as long as you don't use dynamically
> linked libraries, and even then you can't be sure of that, considering the
> comment below the table on that web page.


Thanks for the link. Good to know!
 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments