Glose Structures Anonymes
Un compound statement dont les valeurs ne sont pas precises est uninitialized
Il ne sert a rien de copier des valeurs undefined, donc
struct foo {
int dummy; struct numbers { int one; int two; int three; int four; int five; } bar; }
struct numbers one_two_three_four_five() { return (struct numbers) { .one = 1, .two = 1; .three = 1; .four = 1; .five = 1; } }
int main() { struct foo foo;
foo.dummy = 1; foo.numbers.one = 1; foo.numbers.two = 1; // direct access, fast?
foo = (struct foo){0}; foo.numbers = (struct numbers) { .one = 1, .two = 1; .three = 1; .four = 1; .five = 1; } // create a new object and copy values, slow?
foo = (struct foo){0, 0, 0, 0, 0, 0};
foo.bar= (struct numbers) { .one = 1, .three = 1, .five = 1 } foo.bar= (struct numbers) { .two = 1, .four = 1, } // garbage values should not be copied and overwrite existing values
foo.bar = (struct numbers) { one_two_three_four_five() }; // this should be vectorized }
On devrait pouvoir faire un tableau de structures anonymes
struct damier { struct { char contenu; size_t index; long ligne; long colonne; }[TAILLE_DAMIER]; int cibles[NOMBRE_DIRECTIONS]; } damier, *adamier;
De sorte qu’on puisse écrire damier[5]
Expansion macro[ modifier ]
#define LONG (5) #define P10(exp) 1e##exp P10(LONG)
Devrait resoudre 1e5
, non pas 1eLONG
Version greedy de scanf[ modifier ]
char string[] = “finally” scanf("%*[^l]", &string);
Pouvoir capturer finall
au lieu de final