delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/03/03:43:12

Message-ID: <005401be6551$992b7130$293f8589@gv015029.bgo.nera.no>
From: "Gisle Vanem" <gvanem AT eunet DOT no>
To: <djgpp AT delorie DOT com>
Subject: Re: Real stupid problem.
Date: Wed, 3 Mar 1999 09:40:39 +0100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> said
>On Tue, 2 Mar 1999, Shadow Seeker wrote:
>
>> >If you need to minimize this padding (e.g., if your program uses large
>> >arrays of such structs, where padding will waste a lot of memory), lay
>> >out structures so that the longer members are before the shorter ones. 
>>  No, that won't do, I can't design the structs, I read datafiles that
>> use them. But Endlisnis gave me a clue that works perfectly.
>> 
>>  Just add "__attribute__(packed)" behind the struct and things work
>> just fine.
>
>It's "__attribute__((packed))" (double parentheses).


Why don't people use '#pragma pack(1)' instead.  It's the widely accepted form and
gcc has supported this from ver 2.7.1 AFAIK. And refering section 22.11 in the FAQ 
it seems that '__attribute__((packed))' is buggy (for C++) in gcc 2.7.2.

Gisle V.



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019