Sujet : Re: C89 "bug"
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.cDate : 13. Dec 2024, 14:26:06
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vjhcle$3den0$2@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
Em 12/13/2024 9:56 AM, Michael S escreveu:
On Fri, 13 Dec 2024 09:15:58 -0300
Thiago Adams <thiago.adams@gmail.com> wrote:
Does anyone knows how can I convert this code (external declaration)
to C89?
>
union U {
int i;
double d;
};
>
union U u = {.d=1.2};
>
The problem is that in C89 only the first member of the union is
initialized.
>
union U {
double d;
int i;
};
unfortunately, this solution does not work if we have two objects.
union U {
double d;
int i;
};
union U u1 = { .d=2.2 };
union U u2 = { .i=1 };