4 ms·
"Flat Initializer Lists" is given as an example in K&R C I think, at least the first edition, when writing those extra braces to fill out an initializer must ha
by veltas 4y ago
"Flat Initializer Lists" is given as an example in K&R C I think, at least the first edition, when writing those extra braces to fill out an initializer must have felt very redundant.
These days many compilers will warn if you do this, however, as it is rare people do this and usually indicates a misunderstanding of the type used.
I think it's quite readable though, so it's a shame it causes warnings. What do you think?
struct { const char *name; int age; } records[] = {
"John", 20,
"Bertha", 40,
"Andrew", 30,
};
- blep_ 4y agoI find it slightly worse to read. It's C, so my brain is in "newlines don't matter" reading mode, so I see an array of 6 things and then have to mentally split them back up.