KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I would like to perform a compile-time check on datatype sizes in a C/C++ project, and error on unexpected mismatches. Simple #if sizeof foo_t != sizeof bar_t does not compile - claims that sizeof is not a proper compile-time constant. The desired scope of platforms - at the very least Visual C++ with Win32/64, and GCC on x86/amd64. EDIT : compile-time, not necessarily preprocessor. Just not a run-time error. EDIT2 : the code assumes that wchar_t is 2 bytes. I want a compilation error if it's accidentally compiled with 4-byte wchar's.
Tags (comma-separated)
Save Edits
Cancel