Deutsch   English   Français   Italiano  
<vjhcle$3den0$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Thiago Adams <thiago.adams@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: C89 "bug"
Date: Fri, 13 Dec 2024 10:26:06 -0300
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <vjhcle$3den0$2@dont-email.me>
References: <vjh8hu$3den0$1@dont-email.me> <20241213145639.00003d71@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 13 Dec 2024 14:26:06 +0100 (CET)
Injection-Info: dont-email.me; posting-host="8b9a0b17735b443b8fd85bb0477dd1c9";
	logging-data="3586784"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19ux/ke7g04Lo67SxllLyNPunFvwrAnBm0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:v1hfO1t9jy/3xQf7XXOXRtgk5wM=
Content-Language: en-GB
In-Reply-To: <20241213145639.00003d71@yahoo.com>
Bytes: 1698

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   };