繁体   English   中英

_WIN32, __linux__... 预处理器宏是如何工作的?

[英]How _WIN32, __linux__… preprocessor macro work?

像 GCC 这样的 C 编译器如何定义预处理器宏来检测当前操作系统?

我查看了 GCC 的源代码,发现了这个builtin_define ("_WIN32"); 但我不确定这是否是定义宏的地方。

TL;DR:基本上,是的。 内置宏在目标描述 header 文件中定义。

经常有一本精美的手册可供阅读; 在这种情况下,它是GCC 内部手册 (具体来说,在Run-time target specification部分,但不要从那里开始阅读;你需要一些上下文。)

如果您需要更多信息,请参阅 GCC 文档的完整纲要 (内部文档位于该页面的底部。)

(If you're comfortable using the GNU info reader and you're using a Ubuntu/Debian system, you can install the GCC documentation for your current GCC version with sudo apt-get install gcc-doc ; that includes the GCC internals documentation. )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM