I have code like the following (mixed C / C ++ application)
#include <stdint.h> #define BUFFER_SIZE UINT16_MAX
I expected BUFFER_SIZE be (65535) as UINT16_MAX defined in stdint.h, but instead the compiler complains that UINT16_MAX not defined. Obviously, macro expansion does not occur as we would like.
I could just identify it myself (65535), but I would like to know why this is not working.
Reply to a couple of comments:
ANSWER
So it was __STDC_LIMIT_MACROS , but more complicated.
- #define was in the header file (including stdint.h)
- I had #define
__STDC_LIMIT_MACROS in this file before stdint.h was included - I included this header file in another source file. This other source file is also #include stdint.h and did this before including my header. Therefore, when stdint.h was first turned on
__STDC_LIMIT_MACROS not defined
My solution was to simply add -D__STDC_LIMIT_MACROS to my compiler arguments.
source share