简体   繁体   中英

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

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.

Specifically if you looking to identify the compiler flags within a program it would not be possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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