Search code examples
c-preprocessoravravr-gcc

check from preprocessor if -mint8 is used for compilation


Is there any c macro predefined if compiler option -mint8 is in use?

Background:

I can compile something for avr with the -mint8 compiler option which results in smaller code size. That violates against the c standard, but this is not the problem here.

I simply want to

#ifdef MINT8  // search the name for the macro here
  ...
#endif

Solution

  • AVR Libc tests the value of __INT_MAX__:

    #if __INT_MAX__ == 127
     ...
    #endif
    

    If you include <stdint.h> then it will define __USING_MINT8 as 0 or 1 as appropriate.