3 ms·
Designated Initialization With Compound Literals in C
- gsg 13y agoThe nesting can be taken care of: typedef struct list { int value; struct list *next; } list; #define cons(head, tail) ((list[]){{.value = head, .next = tail}}) list *xs = cons(0, cons(1, cons(2, NULL))); It isn't very useful though. Lifetime issues mean that such lists can't be mixed with dynamically allocated structure, returned from functions, etc.