You can also check the source to determine if an option is active. The EBNF syntax is:
OptionActive = __OPTION_ACTIVE__ ("string")
The above is used in the preprocessor and in C code, as shown:
#if __OPTION_ACTIVE__("-W2") // option -W2 is set #endif void main(void) { int i; if (__OPTION_ACTIVE__("-or")) { i=2; } }
You can check all valid preprocessor options (e.g., options given at the command line, via the default.env or project.ini files, but not options added with the #pragma OPTION: Additional Options). You perform the same check in C code using -Odocf and #pragma OPTION.
As a parameter, only the option itself is tested and not a specific argument of an option.
See the following listing for a valid and an invalid use of __OPTION_ACTIVE__.
#if __OPTION_ACTIVE__("-D") /* true if any -d option is given */ #if __OPTION_ACTIVE__("-DABS") /* specific argument - not allowed */
To check for a specific define use:
#if defined(ABS)
If for some reason the Compiler cannot check the specified option (i.e., options that no longer exist), the Compiler issues the message "C1439: illegal pragma __OPTION_ACTIVE__".