delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2012/07/26/21:45:18

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: RayeR <glaux AT centrum DOT cz>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Upgrading from a bad C compiler
Date: Thu, 26 Jul 2012 18:23:51 -0700 (PDT)
Organization: http://groups.google.com
Lines: 13
Message-ID: <3331145d-900b-4bef-8ad0-f533f0b4a17b@googlegroups.com>
References: <17d4b525-2c31-4c20-b3c5-a7118343e9a5 AT googlegroups DOT com>
<jucp01$p35$1 AT speranza DOT aioe DOT org> <b1f8c389-45f4-43e4-9056-62fc50fc9462 AT googlegroups DOT com>
<juh7c1$7hk$1 AT speranza DOT aioe DOT org>
NNTP-Posting-Host: 78.102.85.249
Mime-Version: 1.0
X-Trace: posting.google.com 1343352232 10899 127.0.0.1 (27 Jul 2012 01:23:52 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: Fri, 27 Jul 2012 01:23:52 +0000 (UTC)
In-Reply-To: <juh7c1$7hk$1@speranza.aioe.org>
Complaints-To: groups-abuse AT google DOT com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=78.102.85.249;
posting-account=Q0wMHAoAAADjYrghh94FTf6YnbpTqZgp
User-Agent: G2/1.0
Bytes: 1883
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id q6R1j1eM015919
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> I&#39;d assume alignment would increase the physical size.  I don&#39;t know if it
> increases sizeof()&#39;s value though.  I would think not...  I would think that
> C should only return the total size for C elements and not padding or
> alignment.

No, sizeof() is called on a structure which is aligned by default it returns total size including padding bytes! Usually 8bit members are extended to 16bits to be placed on even address. If you need a srtucture that match exact size (e.g. reading some header from file to struct in memory) use __attribute__ ((packed)). Then sizeof will return number that is exact sum of all members size.

- Raw text -


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