F
F. Edward Boas
How can you check to see if a type is built-in or typedef'ed? For
example, an 8-bit integer could be u_int8_t, uint8_t, or unsigned
__int8, depending on the OS/compiler. I'd like to write code like:
#if defined(u_int8_t)
typedef u_int8_t BYTE;
#elif defined (uint8_t)
typedef uint8_t BYTE;
#elif defined (__int8)
typedef unsigned __int8 BYTE
#endif
However, this does not work, because built-in and typedef'ed types are
not "defined" according to #ifdef. So two questions: Is there a
work-around? And why doesn't C++ allow the above code?
example, an 8-bit integer could be u_int8_t, uint8_t, or unsigned
__int8, depending on the OS/compiler. I'd like to write code like:
#if defined(u_int8_t)
typedef u_int8_t BYTE;
#elif defined (uint8_t)
typedef uint8_t BYTE;
#elif defined (__int8)
typedef unsigned __int8 BYTE
#endif
However, this does not work, because built-in and typedef'ed types are
not "defined" according to #ifdef. So two questions: Is there a
work-around? And why doesn't C++ allow the above code?