名字错误 [英] name mangling

查看:74
本文介绍了名字错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么不制作名称重整? C ++标准应该是可能的

调用

来自其他C ++编译器的C ++的类和函数

[以及其他语言]

谢谢

解决方案

Megalo写道:


为什么不制作名称重整? C ++标准应该是可能的

调用

来自其他C ++编译器的C ++的类和函数

[以及其他语言]



因为具有不同的修改约定的原因之一是

完全禁止编译器之间的链接。 Mangling不是编译器之间唯一的异构性元素,但是其他问题必须被认为是结构填充,虚函数表,调用

惯例和标准的其他实施方面。


祝福,

Zeppe

11月3日上午8:37,Megalo < m ... @ z.xwrote:


为什么不制作name mangling C ++标准应该是

可以从

其他C ++编译器[和其他语言]调用C ++的类和函数



因为名称重整只是冰山一角。不同的

编译器故意尝试进行不同的修改,以便在链接时出现错误,而不是在
运行时出现未定义的行为。 C ++委员会无法真正解决这个问题,因为任何布局规则都必须依赖于硬件;

通常(即在C的情况下),它是

定义API的平台。到目前为止,很少有平台为此做过这样的事情。

C ++(Intel Itanium,我认为)。对于专有平台(例如,
Solaris,Windows),无论拥有者自己的C ++编译器(Sun CC,VC ++)如何,都可以认为API被定义为

确实如此,但是

这并不总是有详细记录。


-

James Kanze(GABI Software)电子邮件: ja*********@gmail.com

Conseils eninformatiqueorientéeobjet/

Beratung in objektorientierter Datenverarbeitung

9个地方Sémard,78210 St.-Cyr-l''coco,法国,+ 33(0)1 30 23 00 34


----- BEGIN PGP SIGNED MESSAGE -----

哈希:SHA1


Megalo写道:


为什么不制造名称错误 C ++标准应该是可能的

调用

来自其他C ++编译器的C ++的类和函数

[以及其他语言]

谢谢



C ++描述了编程语言,而不是它的实现方式。


例如,如果有人想要创建类似于Java / .NET的C ++运行时环境,那么C ++标准的合规性就不会被打破。如果

标准已经描述了实现细节,那么可能不会违反某些段落。


当前情况,允许编译器创建者轻松引入新的

想法和机制,这可能会使结果代码更有效。


如果你真的想调用C ++函数您可以使用的其他二进制文件

类似于:

externC int function();


Pawel Dziepak

----- BEGIN PGP SIGNATURE -----

版本: GnuPG v1.4.9(GNU / Linux)

评论:在Fedora中使用GnuPG - http://enigmail.mozdev.org


iEYEARECAAYFAkkO6ogACgkQPFW + cUiIHNrV1ACeJE / Q7gq88 + 4RIZT1gxzQK1QN

rmsAnRHfHIM2C2ghr7vzCuxyIuQUYCVF

= SM84

----- END PGP SIGNATURE -----


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

解决方案

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


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


-----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-----


这篇关于名字错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆