Ben Bacarisse said:
John Reye said:
In particular:
It is never possible to use that is a cast, right?
(char [3]) var /* this cast is never allowed, right? */
I do actually believe that a cast is possible:
Example
printf("%s\n", (char [3]) {'h', 'i', '\0'} );
That's not a cast. It's a compound literal.
(Anyone know why that are called that since they need not be compound
and they don't seem to be literals -- at least not like any other C
literals?)
The term makes sense to me. Typically they are used for
"compound" data types (a struct, union, or array); certainly
their most obvious purpose is for "compound" values even if
"ordinary" values are also allowed. As for literal, historically
a "literal" was a memory location (or several) referred to by
giving its contents locally rather than defining it elsewhere and
referring to it using a label. That a 'literal' is an lvalue
rather than an rvalue may seem odd in C but it's consistent with
other uses of the term that predate C (I remember it from various
ancient assembly languages -- IIRC these things were usually
called "literals" but they were just a quick way to refer to a
regular memory location).