3 ms·
C99 has one nice feature compared to C89 that is little talked about: you can initialize local aggregates using expressions that can't be calculated at load-tim
by kazinator 5y ago
C99 has one nice feature compared to C89 that is little talked about: you can initialize local aggregates using expressions that can't be calculated at load-time.
void fun(int x)
{
struct foo = { x }; // not allowed in C89
int bar[3] = { 0, x }; // ditto
}
Chances are the kernel does this because, I think, it's also a GNU89 extension.
- marcan_42 5y agoLinux already uses a lot of C99 features that were GNU extensions before C99, like designated initializers. So in practice, Linux is already C99, and hasn't been buildable on strict C89 compilers in a long time.