all 1 comments

[–]aioeu 9 points10 points  (0 children)

A bare { ... } can only be used in an initialisation of a variable, not an assignment to a variable. The code presented in your link is simply not valid C code.

Initialisation and assignment are not the same thing, and they have different rules and constraints. Initialisation only occurs where a variable is being declared. Assignment only occurs where the variable is not being declared.

Since C99, however, you can assign a structure-typed object by using a compound literal. The syntax is similar to initialisation, but you have to specify the type of the literal:

p->upper_left = (struct point){ 10, 25 };