This is a discussion on Using sizeof( long ) at compile time? within the C Programming forums, part of the General Programming Boards category; Originally Posted by novacain Looked at the #error preprocessor command? Something like #if sizeof(long) != 4 #error Long incorrect size! ...
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Yeah, or, if you know how many bits you want in an unsigned intMaybe I should just do this:
Code:#if UINT_MAX != 0xFFFFFFFF # error "ints aren't 4 bytes here!" #endif
or, if you have the number of "characters" you want an unsigned int to be,Code:#if UINT_MAX != (1 << 32) - 1 #error sizeof(unsigned int) != 4 #endif
Code:#if UINT_MAX != (1 << (4 * CHAR_BIT)) - 1 #error sizeof(unsigned int) != 4 #endif
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.