|
|
|
|
|
by nitrogen
4373 days ago
|
|
Compound literals in C are awesome like it's 1999: Assuming you have this: struct point {
float x, y, z;
};
void do_something_with_point(struct point *p);
You can do this: do_something_with_point(&(struct point){.x = 1.5, .y = 1.5, .z = 3.5});
|
|
Being able to specify a literal for a struct is useful. You can, for instance, put the literal in a macro and use the macro to initialize or reset a struct. It's better than having to write additional functions to do something trivial.