Deutsch   English   Français   Italiano  
<20241213065614.739@kylheku.com>

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

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups: comp.lang.c
Subject: Re: C89 "bug"
Date: Fri, 13 Dec 2024 15:01:13 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <20241213065614.739@kylheku.com>
References: <vjh8hu$3den0$1@dont-email.me>
 <20241213145639.00003d71@yahoo.com> <vjhcle$3den0$2@dont-email.me>
Injection-Date: Fri, 13 Dec 2024 16:01:13 +0100 (CET)
Injection-Info: dont-email.me; posting-host="247d7de8ed76df9f18d4190cb1f7e005";
	logging-data="3653835"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX185B/AYwiIwahpvF1yxpMc2IF8r/uXECYU="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:R3q/TzJgzysrimzA/2JOQxScgSQ=
Bytes: 1559

On 2024-12-13, Thiago Adams <thiago.adams@gmail.com> wrote:
> 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   };

Idea: have several declarations of the union in different translation
units.

/* translation unit for u1 */
union U {
  double d;
  int i;
};
extern union U u1 = { 2.2 };

/* translation unit for u2 */
union U {
  int i;
  double d;
};
extern union U u2 = { 1 };

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca