gpt4 book ai didi

c - C 中的名称修饰

转载 作者:行者123 更新时间:2023-11-30 16:59:49 27 4
gpt4 key购买 nike

是否有任何标准要求名称装饰?

据我所知,大多数(全部?)符合标准的实现都会在每个导出符号的名称中添加下划线前缀。这是由 C、POSIX 或其他标准保证的吗?

最佳答案

我不确定“标准”,但前置下划线似乎是 20 世纪 70 年代以来非常常见的约定。来自 What is the reason function names are prefixed with an underscore by the compiler? :

At the time that UNIX was rewritten in C in about 1974, its authors already had extensive assember language libraries, and it was easier to mangle the names of new C and C-compatible code than to go back and fix all the existing code.

如果您想与 Windows 上的 Microsoft 编译器进行互操作(仅限 win32;win64 不使用修饰,因为它只有一个标准调用约定),则 C 名称是必需的。

https://learn.microsoft.com/en-us/cpp/build/reference/decorated-names

另请参阅:Why do C compilers prepend underscores to external names?

关于c - C 中的名称修饰,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37970360/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com