Namespaces
Variants
Actions

Talk:c/language/compound literal

From cppreference.com

Constructs an unnamed object of specified type in-place, used when a variable of array, struct, or union type would be needed only once.

This incorrectly implies that compound literals of arithmetic types cannot be created, whereas they can. This is useful for opaque types : (type_t){0} is guaranteed to compile and zero-initialize a value of type_t whether type_t is a struct, union, int, and so on.

Shouldn't this sentence be reworded ?

Babbage (talk) 08:35, 10 May 2022 (PDT)

I think it meant to illustrate one motivating use case. I reworded a bit, but feel free to tweak more --Cubbi (talk) 09:14, 10 May 2022 (PDT)