简体   繁体   English

c ++如何将编译器选项检测为字符串

[英]c++ how to detect compiler options as string

Is there any way to retrieve the options which were used to compile a program? 有没有办法检索用于编译程序的选项? Example: -Wno-unused-result -Werror=declaration-after-statement -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security etc... 示例: -Wno-unused-result -Werror=declaration-after-statement -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security等...

I've seen programs that had this in about form, but I can't find if there is some macro that contains the options which were passed to compiler as a string. 我已经看到过具有这种形式的程序,但我找不到是否有一些宏包含作为字符串传递给编译器的选项。

Is there some simple, preferably cross-platform way to detect this so that I could do something like 是否有一些简单的,最好是跨平台的方式来检测这个,以便我可以做类似的事情

char *options = GCC_COMPILER_FLAGS;

Check the CPPFLAGS environment variable, that usually has the flags which are used to compile a program. 检查CPPFLAGS环境变量,该变量通常具有用于编译程序的标志。

Specifically if you looking to identify the compiler flags within a program it would not be possible. 特别是如果您希望在程序中识别编译器标志,那将是不可能的。

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

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