There are predefined macros such as __OPTIMIZE__ (defined in all optimizing compilations) and __OPTIMIZE_SIZE__ (defined if the compiler is optimizing for size).
I use these macros to check if the correct optimization level is set for the release target, if not I print out a warning.
Is there a possibility to check whether the optimization level -Ofast is set or not?
Possibly something like __OPTIMIZE_FAST__ or __OPTIMIZE_SPEED__.
I checked the ARMCC command line options and it seems there's no
-Ofastlike in many other compilers. However if the behavior is the same as in GCC/Clang/ICC... then-Ofastis essentially just-O3with--fpmode=fastso you can check it with__FP_FAST, probably in conjunction with__OPTIMISE_LEVELIn GCC you can use
__FAST_MATH__.__NO_MATH_ERRNO__may also be used although it may not be an exact match because that'll also be defined if-fno-math-errnois specified