Last active
November 30, 2018 02:30
-
-
Save leiless/941d26b9d36da87fdfd1dc5c922acfd0 to your computer and use it in GitHub Desktop.
Simplified BUILD_BUG_ON(condition) macro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifdef DEBUG | |
| #define BUILD_BUG_ON(cond) ((void) sizeof(char[-!(cond)])) | |
| #define BUILD_BUG_ON2(cond) ((void) (char[1]){[!(cond)] = 0}) /* Nonoptimal */ | |
| #else | |
| #define BUILD_BUG_ON(cond) ((void) (cond)) | |
| #define BUILD_BUG_ON2(cond) ((void) (cond)) | |
| #endif | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment