473,799 Members | 3,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3001
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.xwrot e:
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 objektorientier ter Datenverarbeitu ng
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

iEYEARECAAYFAkk O6ogACgkQPFW+cU iIHNrV1ACeJE/Q7gq88+4RIZT1gx zQK1QN
rmsAnRHfHIM2C2g hr7vzCuxyIuQUYC VF
=SM84
-----END PGP SIGNATURE-----
Nov 3 '08 #4

"Pawel Dziepak" <pd******@quarn os.orgha scritto nel messaggio
news:ge******** **@registered.m otzarella.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.xwrot e:
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

iEYEARECAAYFAkk PW34ACgkQPFW+cU iIHNqK+QCglQtOd +7WPAsiUIdlkwaH ePkg
8ukAn0i3E5/bwTnI7niGSWG9Cd JAkfzU
=CFmT
-----END PGP SIGNATURE-----
Nov 3 '08 #7
On Nov 3, 2:41*pm, "Megalo" <m...@z.xwrot e:
"Pawel Dziepak" <pdzie...@quarn os.orgha scritto nel
messaggionews:g e**********@reg istered.motzare lla.org...
[...]
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 objektorientier ter Datenverarbeitu ng
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...@quarn os.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 objektorientier ter Datenverarbeitu ng
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

iEYEARECAAYFAkk PgFEACgkQPFW+cU iIHNrTyQCfcYSjp zx+LbLpceunror5 Rmix
iQgAn3GVputZ8So 5E9LXECIej4cYdH A+
=0QjE
-----END PGP SIGNATURE-----
Nov 3 '08 #10

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

Similar topics

5
2018
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 making class variables
4
1889
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. when I link the 2 binaries in VC++ it works fine but with DDK this gives as error saying _foo@8 not found.
1
2525
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 files defining their objects and functions, and *.so files (I'm on a Sun Sparc machine running Solaris) containing the implementation of the functions. I'm compiling with the GNU g++ compiler. According to the
6
6528
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 "yes", but i vaguely remember having read that it's not exactly like that one might say that "name mangling" is a part of c++ compiler specification and is a naming scheme to support function overloading
1
1910
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, it contains symbols (entry points) like: jpeg_read_header I'm trying to link my program with this library. My program is in Visual C++. The link fails with link-time errors such as:
6
1721
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 into google to no avail. Dave.
5
1967
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 account ?I know that C++ standard does not tell anything about name mangling and only talks bout function overloading. But, I have observed that the Metrowerks Code Warrior compiler does take return type into the mangling scheme. Is it not a bug...
8
3140
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 anyone tell in detail as to what name mangling is all about?
4
1974
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
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9544
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10030
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7570
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4145
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.