This compiles without warnings using clang.
typedef struct {
int option;
int value;
} someType;
someType *init(someType *ptr) {
*ptr = (someType) {
Yu Hao has answered with the standard, now some vulgarization.
Whenever you see a compound literal like:
struct S *s;
s = &(struct S){1};
you can replace it with:
struct S *s;
struct S __HIDDEN_NAME__ = {1};
s = &__HIDDEN_NAME__;
So:
struct S {int i;};
/* static: lives for the entire program. */
struct S *s = &(struct S){1};
int main() {
/* Lives inside main, and any function called from main. */
s = &(struct S){1};
/* Only lives in this block. */
{
s = &(struct S){1};
}
/* Undefined Behavior: lifetime has ended. */
s->i;
}