Article View: fr.comp.lang.c
Article #15618Re: alignements struct/tableaux
From: Emmanuel Delahaye
Date: Sat, 17 Sep 2005 18:08
Date: Sat, 17 Sep 2005 18:08
35 lines
1687 bytes
1687 bytes
Pierre Habouzit wrote on 17/09/05 :
> typedef struct foo foo;
>
> struct my_union {
> union {
> foo *array[2];
> struct {
> foo *first;
> foo *second;
> }
> }
> } my_union;
>
> soit 'bar' du type my_union, en supposant que tous les membres sont allou�s.
>
> est ce que je suis toujours sur que :
>
> &bar->array[0] == &bar->first
Oui, mais par contre
> &bar->array[1] == &bar->second
ceci n'est pas garanti par la norme.
D'une fa�on g�n�rale, ce n'est pas une bonne id�e d'�crire dans un
membre d'une union est de lire dans un autre. Une union, c'est pas fait
pour �a.
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html
.sig under repair
Technical Details
Message-ID:
<mn.8cb87d59c7031bee.15512@YOURBRAnoos.fr>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!infeed-3.proxad.net!news18-e.free.fr!not-for-mailReferences:
<432c52d5$0$9425$626a14ce@news.free.fr>Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,2ab126dba8e5e645 X-Google-Attributes: gidf9822,public X-Google-Language: FRENCH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!infeed-3.proxad.net!news18-e.free.fr!not-for-mail Subject: Re: alignements struct/tableaux From: "Emmanuel Delahaye" <emdel@YOURBRAnoos.fr> References: <432c52d5$0$9425$626a14ce@news.free.fr> Newsgroups: fr.comp.lang.c Message-ID: <mn.8cb87d59c7031bee.15512@YOURBRAnoos.fr> X-Newsreader: MesNews/1.04.00.00-fr Date: Sat, 17 Sep 2005 20:08:07 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15"; format=flowed Content-Transfer-Encoding: 8bit Lines: 37 Organization: Guest of ProXad - France NNTP-Posting-Date: 17 Sep 2005 20:08:10 MEST NNTP-Posting-Host: 81.65.109.78 X-Trace: 1126980490 news18-e.free.fr 971 81.65.109.78:25869 X-Complaints-To: abuse@proxad.net