2 ms·
{0} is standard C. {} is currently a (common) compiler extension but will be standard C23: https://open-std.org/JTC1/SC22/WG14/www/docs/n2900.htm https://open-s
by dropbear3 3y ago
{0} is standard C. {} is currently a (common) compiler extension but will be standard C23: https://open-std.org/JTC1/SC22/WG14/www/docs/n2900.htm https://open-std.org/JTC1/SC22/WG14/www/docs/n2900.htm
- dundarious 3y agoYes, it's a bit frustrating, especially for headers with inline/macro code. And for headers, requiring C23 doesn't seem sensible for quite some time. I define a macro: #ifdef __cplusplus # define ZERO_INIT {} #else # define ZERO_INIT {0} #endif Works for arrays, aggregates, scalars, etc., but I just use it for arrays and aggregates: `char buf[32] = ZERO_INIT; struct X x = ZERO_INIT;`