|
|
|
|
|
by cozzyd
17 days ago
|
|
The idiom I usually use is to define a DEFAULT_FOO_PARAMS like struct foo { int Z; int A; double E, double v };
#define DEFAULT_FOO_PARAMS .Z = 1, v = 3e8
foo_fn ( &(struct foo){ DEFAULT_FOO_PARAMS, .Z =2, .A = 4, .E = 1 });
But I do sort of wish there was a language-supported way to set defaults for a designated initializer in the struct definition (like C++ default values) to avoid having to write DEFAULT_FOO_PARAMS there. |
|