I've asked here before about how to define a variable of a specific size, and I got a good answer for most situations, but unfortunately a bad answer for mine. I'm not in a position where porting all of libc to my OS is either practical or possible, so I made a highly configurable header to serve the same purpose as stdint, but w/o including a thousand other headers. Here it is. You're free to use it. Any suggestions? Can you think of a system which uses data sizes/types this couldn't be configured for by only modifying the lines directly under "/* All values are determined from these */"?Is "typedef" correct, or should I use "#define"?Code:#ifndef STDVAR_H #define STDVAR_H 1 /* All values are determined from these */ #define BYTE_BITS 8 #define BYTE_BYTES 1 #define WORD_BYTES BYTE_BYTES * 2 #define DWORD_BYTES WORD_BYTES * 2 #define QWORD_BYTES DWORD_BYTES * 2 /* Define a byte sized type */ #if WIDTH(unsigned char) == BYTE_WIDTH typedef byte_t unsigned char; #else #error No byte sized type available! #endif /* Define a word sized type */ #if WIDTH(unsigned wchar) == WORD_WIDTH typedef word_t unsigned wchar; #else #error No word sized type available! #endif /* Define a dword sized type */ #if WIDTH(unsigned int) == DWORD_WIDTH typedef dword_t unsigned int; #elif WIDTH(unsigned short) == DWORD_WIDTH typedef dword_t unsigned short; #else #error No dword sized type available! #endif /* Define a qword sized type */ #if WIDTH(unsigned long long) == QWORD_WIDTH typedef qword_t unsigned long long; #elif WIDTH(unsigned int) == QWORD_WIDTH typedef qword_t unsigned int; #else #error No qword sized type available! #endif #define WIDTH(type) (sizeof(type) * BYTE_BITS) #define MAX_VAL(type) ((1 << (WIDTH(TYPE)) - 1) #define BYTE_WIDTH BYTE_BYTES * BYTE_BITS #define WORD_WIDTH WORD_BYTES * BYTE_BITS #define DWORD_WIDTH DWORD_BYTES * BYTE_BITS #define QWORD_WIDTH QWORD_BYTES * BYTE_BITS #define MAX_BYTE ((1 << (BYTE_WIDTH) - 1) #define MAX_WORD ((1 << (WORD_WIDTH) - 1) #define MAX_DWORD ((1 << (DWORD_WIDTH) - 1) #define MAX_QWORD ((1 << (QWORD_WIDTH) - 1) #endif /* STDVAR_H */