3 ms·
Ah, neat. A version of static_assert for C. What kinds of expressions can it actually evaluate, though?
by an_account_name 10y ago
Ah, neat. A version of static_assert for C. What kinds of expressions can it actually evaluate, though?
- viraptor 10y agoAny constant expression. In the kernel it's mostly non-zero flags, sizes of things, etc. See https://github.com/torvalds/linux/search?utf8=%E2%9C%93&q=BUILD_BUG_ON_ZERO https://github.com/torvalds/linux/search?utf8=%E2%9C%93&q=BU... There's also a fun compile time check for arrays: https://github.com/torvalds/linux/blob/1001354ca34179f3db924eb66672442a173147dc/include/linux/compiler-gcc.h#L64 https://github.com/torvalds/linux/blob/1001354ca34179f3db924...