c initialization algorithm

Liste des GroupesRevenir à cl c  
Sujet : c initialization algorithm
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.c
Date : 13. Oct 2024, 22:35:03
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vehee7$r8ri$1@dont-email.me>
User-Agent : Mozilla Thunderbird
The algorithm for C initialization as described in the standard and implemented in gcc allow this.
struct X{
     int a,b,c;
};
int main()
{
     struct X x = {.a=1,2,3,.a=1, 2, 3};
}
https://godbolt.org/z/7naedbEM6
Basically, when a designed initializer is found the "cursor" goes to that member and the following members are initialized in order.
struct X{
     int a,b,c;
};
int main()
{
     struct X x = {.a=1,2,3,.a=1, 2, 3, .a=1, 4, 5};
}

Date Sujet#  Auteur
13 Oct 24 * c initialization algorithm7Thiago Adams
14 Oct 24 `* Re: c initialization algorithm6Kaz Kylheku
14 Oct 24  `* Re: c initialization algorithm5Tim Rentsch
14 Oct 24   `* Re: c initialization algorithm4Thiago Adams
15 Oct 24    `* Re: c initialization algorithm3Thiago Adams
15 Oct 24     `* Re: c initialization algorithm2Thiago Adams
15 Oct 24      `- Re: c initialization algorithm1Kaz Kylheku

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal