name decoration

J

JKop

Bern posted:
hi all,

what is the rule for decorating a symbol in c++?


It's implementation-specific. For instance, there's a
certain way of doing it on Win32. It's commonly referred to
as "name mangling".

-JKop
 
P

Phlip

Bern said:
what is the rule for decorating a symbol in c++?

That rule, if any, is implementation specific. I assume you are talking
about name mangling.

Do you have an outer problem, or did you just hear the term "name
decoration" somewhere.

What happens is translation unit A compiles, and its function Foo() turns
into fryingpan_Foo(). Translation unit B compiles extern void Foo(), and its
object file contains a link out to fryingpan_Foo(). The only relevant thing
is the two decorations match; the decorations' contents are irrelevant.

Your compiler author might also write a code browser that reverses the
decoration into its component types.
 
P

Pete Becker

JKop said:
Bern posted:



It's implementation-specific. For instance, there's a
certain way of doing it on Win32. It's commonly referred to
as "name mangling".

Each compiler, Win32 or otherwise, has its own way of doing name
mangling. Some even call it by a different name, i.e. "name decoration."
 
R

Rolf Magnus

Please don't top-post. Rearranged.
is the name decoration for C compilers standardised?

No. Most of them don't have any AFAIK, because all the C++ language
features that would need it, like classes, namespaces, templates and
function overloading) aren't available in C.
 
P

Pete Becker

Bern said:
is the name decoration for C compilers standardised?

Most C compiler stick an underscore in front of the names of identifiers
that are defined in user code. But that's not standardized. Neither is
name mangling for C++ compilers.
 
R

Ron Natalie

Rolf Magnus said:
No. Most of them don't have any AFAIK, because all the C++ language
features that would need it, like classes, namespaces, templates and
function overloading) aren't available in C.
In actuality, trivial decoration IS added in most C compilers. Global C
symbols get underscores prepended to them to avoid collision with other
runtime symbols (mostly historical).
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top