473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

name mangling

why not make "name mangling" of C++ standard so should be possible
to call
the classes and the functions of C++ from other C++ compiler
[and other language too]
thanks

Nov 3 '08 #1
14 2965
Megalo wrote:
why not make "name mangling" of C++ standard so should be possible
to call
the classes and the functions of C++ from other C++ compiler
[and other language too]
because one of the reason in having different mangling conventions is
exactly to forbid inter-compilers linking. Mangling is not the only
element of heterogeneity between compilers, but other issues have to be
considered as structure paddings, virtual functions tables, calling
conventions, and other implementation aspects of the standard.

Best wishes,

Zeppe

Nov 3 '08 #2
On Nov 3, 8:37 am, "Megalo" <m...@z.xwrote:
why not make "name mangling" of C++ standard so should be
possible to call the classes and the functions of C++ from
other C++ compiler [and other language too]
Because name mangling is only the tip of the iceberg. Different
compilers intentionally try to have different mangling, so that
you get an error at link time, rather than undefined behavior at
runtime. The C++ committee can't really address the issue,
because any layout rules would have to depend on the hardware;
normally (i.e. in the case of C), it is the platform which
defines the API. To date, very few platforms have done this for
C++ (Intel Itanium, I think). For proprietary platforms (e.g.
Solaris, Windows), one can argue that the API is defined as
whatever the owner's own C++ compiler (Sun CC, VC++) does, but
this isn't always well documented.

--
James Kanze (GABI Software) email:ja*********@gmail.com
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

Nov 3 '08 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Megalo wrote:
why not make "name mangling" of C++ standard so should be possible
to call
the classes and the functions of C++ from other C++ compiler
[and other language too]
thanks
C++ describes the programming language, not the way it is implemented.

For example, if somebody wants to create C++ runtime environment similar
to Java/.NET's ones, C++ standard compliance won't be broken. If
standard had described implementation details, it wouldn't have been
possible not to disobey some paragraphs.

Current situations, allow compilers creators to easily introduce new
ideas and mechanism that probably will make result code more efficient.

If you really want to call C++ function from other binaries you can use
things like:
extern "C" int function();

Pawel Dziepak
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkkO6ogACgkQPFW+cUiIHNrV1ACeJE/Q7gq88+4RIZT1gxzQK1QN
rmsAnRHfHIM2C2ghr7vzCuxyIuQUYCVF
=SM84
-----END PGP SIGNATURE-----
Nov 3 '08 #4

"Pawel Dziepak" <pd******@quarnos.orgha scritto nel messaggio
news:ge**********@registered.motzarella.org...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Megalo wrote:
>why not make "name mangling" of C++ standard so should be possible
to call
the classes and the functions of C++ from other C++ compiler
[and other language too]
thanks

C++ describes the programming language, not the way it is implemented.

For example, if somebody wants to create C++ runtime environment similar
to Java/.NET's ones, C++ standard compliance won't be broken. If
standard had described implementation details, it wouldn't have been
possible not to disobey some paragraphs.
the above is also true
Current situations, allow compilers creators to easily introduce new
ideas and mechanism that probably will make result code more efficient.

If you really want to call C++ function from other binaries you can use
things like:
extern "C" int function();
better
extern "C++" int function();

because extern "C" has already the meaning for "C function"

for me calling c++ function written in a assembly file from a
c++ program was ok
Pawel Dziepak


Nov 3 '08 #5
On Nov 3, 1:37*am, "Megalo" <m...@z.xwrote:
why not make "name mangling" of C++ standard so should be possible
to call
the classes and the functions of C++ from other C++ compiler
[and other language too]
thanks
Wasn't name mangling implemented because of unevolved linker
technology when C++ was being designed? Something about not being able
to associate type information with symbols in a linker? And doesn't
modern linker technology provide mechanisms that would make name
mangling obsolete? Perhaps not all compilers do mangling anymore??
Nov 3 '08 #6
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

tonytech08 wrote:
Wasn't name mangling implemented because of unevolved linker
technology when C++ was being designed? Something about not being able
to associate type information with symbols in a linker? And doesn't
modern linker technology provide mechanisms that would make name
mangling obsolete? Perhaps not all compilers do mangling anymore??
You can associate type information by adding type name to the function
name. That's how that information is (in general) stored. Technology
wasn't a problem. If you wanted not to change the symbol string *and*
store type information you would have to invent new executable and/or
relocatable files format (or improve existing ones), what is not a good
idea.

If all compilers used the same name mangling convention, there wouldn't
be such problem, despite the fact that name mangling would still be done.

Anyway, I don't think that it is a C++ standard thing to indirectly
create C++ compliant executable and/or relocatable file format.

Pawel Dziepak

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkkPW34ACgkQPFW+cUiIHNqK+QCglQtOd+7WPA siUIdlkwaHePkg
8ukAn0i3E5/bwTnI7niGSWG9CdJAkfzU
=CFmT
-----END PGP SIGNATURE-----
Nov 3 '08 #7
On Nov 3, 2:41*pm, "Megalo" <m...@z.xwrote:
"Pawel Dziepak" <pdzie...@quarnos.orgha scritto nel
messaggionews:ge**********@registered.motzarella.o rg...
[...]
Current situations, allow compilers creators to easily
introduce new ideas and mechanism that probably will make
result code more efficient.
If you really want to call C++ function from other binaries
you can use things like:
extern "C" int function();
better
extern *"C++" *int function();
That's the default.
because extern "C" has already the meaning for "C function"
I think his point was that almost all other langauges have the
capability to call a C function, so if you make your C++
function look like a C function, they can call it.

--
James Kanze (GABI Software) email:ja*********@gmail.com
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
Nov 3 '08 #8
On Nov 3, 9:13*pm, Pawel Dziepak <pdzie...@quarnos.orgwrote:
tonytech08 wrote:
Wasn't name mangling implemented because of unevolved linker
technology when C++ was being designed? Something about not
being able to associate type information with symbols in a
linker? And doesn't modern linker technology provide
mechanisms that would make name mangling obsolete? Perhaps
not all compilers do mangling anymore??
You can associate type information by adding type name to the
function name. That's how that information is (in general)
stored. Technology wasn't a problem. If you wanted not to
change the symbol string *and* store type information you
would have to invent new executable and/or relocatable files
format (or improve existing ones), what is not a good idea.
Why not? I uses a linker as early as 1979 which supported
additional information about the function (other than just the
name). Mangling was introduced as a quick and dirty solution to
make things work with an existing linker (which was primitive
even by the standards back then). It turned out to work fairly
well, however, so no one has been motivated to develope other
solutions.
If all compilers used the same name mangling convention, there
wouldn't be such problem, despite the fact that name mangling
would still be done.
The problem isn't that names are mangled differently. The
problem is that classes are laid out differently.

--
James Kanze (GABI Software) email:ja*********@gmail.com
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
Nov 3 '08 #9
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Kanze wrote:
Why not? I uses a linker as early as 1979 which supported
additional information about the function (other than just the
name). Mangling was introduced as a quick and dirty solution to
make things work with an existing linker (which was primitive
even by the standards back then). It turned out to work fairly
well, however, so no one has been motivated to develope other
solutions.
Currently, on the majority of unix systems the main format is ELF which
doesn't provide such possibilities to save type information in other way
than modifying symbol's name. Of course, changing/improving that format
would make many things easier, but breaking compliance is not affordable
for people and companies that creates systems. Problems that would
appear are just more serious that benefits you can take from introducing
such format.

Pawel Dziepak
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkkPgFEACgkQPFW+cUiIHNrTyQCfcYSjpzx+Lb Lpceunror5Rmix
iQgAn3GVputZ8So5E9LXECIej4cYdHA+
=0QjE
-----END PGP SIGNATURE-----
Nov 3 '08 #10
>"James Kanze" <ja*********@gmail.comha scritto nel messaggio
>news:6582fa2d-0c67-4493-9207->7c**********@a29g2000pra.googlegroups.com...
On Nov 3, 2:41 pm, "Megalo" <m...@z.xwrote:
>"Pawel Dziepak" <pdzie...@quarnos.orgha scritto nel
messaggionews:ge**********@registered.motzarella. org...
extern "C" int function();
>better
extern "C++" int function();
>That's the default.
>because extern "C" has already the meaning for "C function"
>I think his point was that almost all other langauges have the
capability to call a C function, so if you make your C++
function look like a C function, they can call it.
so you think that a
C++ [class] function in a .dll file
could have a name usable of a C language?

i would say their name should be the argument size they have, its individual
size
the way of call that function (stdcall ccall etc)

for example
int f(int, int, int)
could have the name

stdcall$int@32$f$int@32$int@32$int@32

if i have a type X where sizeof(X)==64
int f(X, X, X)
stdcall$int@32$f$X@64$X@64$X@64

it is the caller language that has to define type X, int32, in the
way it is like in the memory the C++ one


Nov 4 '08 #11
On 3 Nov, 11:59, Zeppe <ze...@remove.all.this.long.comment.yahoo.it>
wrote:
Megalo wrote:
why not make "name mangling" of C++ standard so should be possible
to call
the classes and the functions of C++ from other C++ compiler
[and other language too]

because one of the reason in having different mangling conventions is
exactly to forbid inter-compilers linking.
why would you want to forbid ICL? yes I read the rest of your post.
It didn't help.
Mangling is not the only
element of heterogeneity between compilers, but other issues have to be
considered as structure paddings, virtual functions tables, calling
conventions, and other implementation aspects of the standard.

--
Nick Keighley
Nov 4 '08 #12
Nick Keighley wrote:
On 3 Nov, 11:59, Zeppe <ze...@remove.all.this.long.comment.yahoo.it>
wrote:
>Megalo wrote:
>>why not make "name mangling" of C++ standard so should be possible
to call
the classes and the functions of C++ from other C++ compiler
[and other language too]
because one of the reason in having different mangling conventions is
exactly to forbid inter-compilers linking.

why would you want to forbid ICL? yes I read the rest of your post.
It didn't help.
Because boastful, explicit compilation failure is better than silent,
enigmatic, random run-time crash due to different conventions used by
different compilers that are not required to agree on some
implementation details whose standardisation would be limiting in
respect to the wideness of requirements satisfied by these compilers.

Best wishes,

Zeppe
Nov 4 '08 #13

"Megalo" <m@z.xha scritto nel messaggio
news:49**********************@reader2.news.tin.it. ..
"James Kanze" <ja*********@gmail.comha scritto nel messaggio
news:6582fa2d-0c67-4493-9207->7c**********@a29g2000pra.googlegroups.com...
On Nov 3, 2:41 pm, "Megalo" <m...@z.xwrote:
>>"Pawel Dziepak" <pdzie...@quarnos.orgha scritto nel
messaggionews:ge**********@registered.motzarella .org...
>extern "C" int function();
>>better
extern "C++" int function();
>>That's the default.
>>because extern "C" has already the meaning for "C function"
>>I think his point was that almost all other langauges have the
capability to call a C function, so if you make your C++
function look like a C function, they can call it.

so you think that a
C++ [class] function in a .dll file
could have a name usable of a C language?

i would say their name should be the argument size they have, its
individual
size
the way of call that function (stdcall ccall etc)

for example
int f(int, int, int)
could have the name

stdcall$int@32$f$int@32$int@32$int@32

if i have a type X where sizeof(X)==64
int f(X, X, X)
stdcall$int@32$f$X@64$X@64$X@64
if X=={8bits, 8bits, 32bits}

and i have the function
int f(X**, X*, X)

the name could be
stdcall$int@32$f$X@PP@8@8@32$X@P@8@8@32$X@N@8@8@32

it is the caller language that has to define type X, int32, in the
way it is like in the memory the C++ one



Nov 5 '08 #14
On Nov 4, 10:01 am, "Megalo" <m...@z.xwrote:
"James Kanze" <james.ka...@gmail.comha scritto nel messaggio
news:6582fa2d-0c67-4493-9207->7c157227e__BEGIN_MASK_n#9g02mG7!__...__********** ************@a29g2000pra.googlegroups.com...
On Nov 3, 2:41 pm, "Megalo" <m...@z.xwrote:
"Pawel Dziepak" <pdzie...@quarnos.orgha scritto nel
messaggionews:ge**********@registered.motzarella.o rg...
extern "C" int function();
better
extern "C++" int function();
That's the default.
because extern "C" has already the meaning for "C function"
I think his point was that almost all other langauges have the
capability to call a C function, so if you make your C++
function look like a C function, they can call it.
so you think that a
C++ [class] function in a .dll file
could have a name usable of a C language?
Who cares about the name? Obviously, another language cannot
call a C++ member function unless it also knows how the C++
compiler implements classes, etc.
i would say their name should be the argument size they have,
its individual size the way of call that function (stdcall
ccall etc)
Why? Once you've said `extern "C"', you've told the compiler
all it needs to know.

--
James Kanze (GABI Software) email:ja*********@gmail.com
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
Nov 5 '08 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steven Bethard | last post by:
Philippe C. Martin wrote: > class Debug_Stderr: > __m_text = '' > __m_log_text = None > __m_dbg = None > __m_refresh_count = 0 <rant> I don't see the benefit in 99.9% of cases for...
4
by: sunny | last post by:
Hi, I was trying to call a function in an an asm file from a C file(driver). In c file the funcrtion is defined as: extern int foo(int,int); In the asm file the function is defined as _foo. ...
1
by: Tim Slattery | last post by:
Does the C++ language standard mandate a particular name-mangling method? I'm trying to use the Entrust toolkit to create a C++ program that encrypts and decrypts files. Entrust supplies header...
6
by: yyy | last post by:
my question is rather theoretical than practical in the pure programming aspect... is "name mangling" the same as "name decorating" ? browsing the web, you might find multiple people saying...
1
by: noleander | last post by:
I need to use a library supplied by someone else: libjpeg.lib. This is a plain C library. I do not have the source code. I do have the header *.h files. When I run dumpbin on the libjpeg.lib,...
6
by: David Wade | last post by:
Folks, Does any one know of any "name mangling" software that allows standard C with long names to be linked? Any suggestions for a better place to look? I have tried putting various searchs...
5
by: Subhransu Sahoo | last post by:
Hi All, Does the C++ standard tell function overloading can't be done with the return types of two functions ? If so, is it true that the name mangling scheme does not take the return type into...
8
by: sam_cit | last post by:
Hi Everyone, I read somwhere that c++ compiler does name mangling of functions which is why c source code can't invoke functions from object files that were generated using c++ compiler. Can...
4
by: jason.cipriani | last post by:
Does anybody know if C++0x is going to change C++ name mangling at all? Such as, standardizing name mangling instead of leaving it up to the compiler? Jason
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.