Skip to content

Instantly share code, notes, and snippets.

@mlafeldt
Created March 20, 2012 10:18
Show Gist options
  • Select an option

  • Save mlafeldt/2133862 to your computer and use it in GitHub Desktop.

Select an option

Save mlafeldt/2133862 to your computer and use it in GitHub Desktop.
[C] ':-!!'
/* From http://stackoverflow.com/questions/9229601/what-is-it-in-c-code */
/* Force a compilation error if condition is true, but also produce a
result (of value 0 and type size_t), so the expression can be used
e.g. in a structure initializer (or where-ever else comma expressions
aren't permitted). */
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment