🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.lang.c
Article #15004

Re: Struct/Union avec les memes champs

#15004
From: Antoine Leca
Date: Wed, 19 Oct 2005 12:20
41 lines
2139 bytes
Pierre Habouzit wrote:

> De plus, tu ne peux m�me pas faire ca :
> struct {
>     union {
>         uint32_t arr32[N];
>         uint16_t arr16[N*2];
>         uint8_t  arr16[N*4];
>     };
> }

Euh... en fait tu peux le faire (mais tu ne dois, comme tu l'expliques).

> d�j� parce que en fait les uint*_t ne font pas forc�ment exactement *
> bits en fait,

Dans la norme C99, si. C'est un cas expr�s.

Si tu veux ceux � qui ne font pas exactement �, utilise uint_leastN_t.
Par contre, la norme ne garantit pas que ces types existent toujours, donc
ce code devrait �tre gard� par des

    #if defined  UINTn_MAX || ! defined UINT_LEASTn_MAX

et par tant n'est pas strictement conforme.

Pour le reste c'est d'accord.


> mais surtout parce que tu vas alors rencontrer des
> probl�mes d'endianess et donc �crire du code non portable si tu fais
> de tels alias.

Oui.

<PINAILLEUR>
... si tu /utilises/ de tels alias.
</PINAILLEUR>


Antoine
Technical Details
Message-ID: <dj5dlo$4ia$1@shakotay.alphanet.ch>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gandi!gandi.net!freenix!news.alphanet.ch!alphanet.ch!not-for-mail
References: <slrndlbo6u.9sr.Marc.Boyer@localhost.localdomain> <4355f8d5$0$623$626a14ce@news.free.fr>

Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,eb7f26af12505976
X-Google-Attributes: gidf9822,public
X-Google-Language: FRENCH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gandi!gandi.net!freenix!news.alphanet.ch!alphanet.ch!not-for-mail
From: "Antoine Leca" <root@localhost.invalid>
Newsgroups: fr.comp.lang.c
Subject: Re: Struct/Union avec les memes champs
Date: Wed, 19 Oct 2005 14:20:07 +0200
Organization: Posted through ALPHANET (http://www.alphanet.ch/)
Lines: 42
Sender: antoinel@212.111.102.30
Message-ID: <dj5dlo$4ia$1@shakotay.alphanet.ch>
References: <slrndlbo6u.9sr.Marc.Boyer@localhost.localdomain> <4355f8d5$0$623$626a14ce@news.free.fr>
NNTP-Posting-Host: 212.111.102.30
Mime-Version: 1.0
Content-Type: text/plain;
 charset="iso-8859-15"
Content-Transfer-Encoding: 8bit
X-Trace: shakotay.alphanet.ch 1129724409 4682 212.111.102.30 (19 Oct 2005 12:20:09 GMT)
X-Complaints-To: usenet@alphanet.ch
NNTP-Posting-Date: Wed, 19 Oct 2005 12:20:09 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506