gpt4 book ai didi

python - 在 python 源代码中使用 __cplusplus

转载 作者:太空宇宙 更新时间:2023-11-04 01:00:29 27 4
gpt4 key购买 nike

python源码中头文件中的follow有什么用

#ifdef __cplusplus
extern "C" {
#endif

这是否意味着 Python 为我们提供了使用 C++ 编译器构建代码的能力。如果是,那么使用 C 和 C++ 编译器构建 python 源代码之间有什么区别吗

最佳答案

Python API 仍然是纯 C 语言。这些指令仅允许在 C++ 代码中包含 header 。

__cplusplus 宏是在使用 C++ 编译器编译代码时隐式定义的。因此,只有当看到它的编译器支持它时,才会添加 extern "C" 规范。

关于python - 在 python 源代码中使用 __cplusplus,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41823304/

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