Mail Archives: djgpp/1996/05/11/17:52:06
Xref: | news2.mv.net comp.os.msdos.djgpp:3698
|
From: | Shawn Hargreaves <slh100 AT york DOT ac DOT uk>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: more sizeof questions
|
Date: | Thu, 9 May 1996 10:52:13 +0100
|
Organization: | The University of York, UK
|
Lines: | 30
|
Message-ID: | <Pine.SGI.3.91.960509104849.8470A-100000@tower.york.ac.uk>
|
References: | <199605090048 DOT UAA09442 AT eelab DOT newpaltz DOT edu>
|
NNTP-Posting-Host: | tower.york.ac.uk
|
Mime-Version: | 1.0
|
In-Reply-To: | <199605090048.UAA09442@eelab.newpaltz.edu>
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
On Wed, 8 May 1996, John Fortin wrote:
> OK, I'm a bit confused..(nothing new i'm afraid)... The structure
> below was taken from the VESA 1.2 spec. sizeof(_VGAInfoBlock) should
> be 256. DJGPP gives 260. What's up with this. A previous posting
> mentioned 4 byte boundaries, but 256 is divisable by 4. Any Ideas??
>
> typedef struct
> {
> DWORD VESASignature; 4
> WORD VESAVersion; 2
> DWORD OEMStringPointer; 4
The OEMStringPointer is 32 bits, but follows a 16 bit value. This would
put it at a non-dword address, so gcc adds two bytes between the two.
Normally this is a Good Thing (makes your code faster). If you are
working with an already specified structure (eg. the VESA spec) it is a
pain, and you have to add __attribute__ ((packed)) after each of your
variables.
btw. this is one good reason not to dump structures into files just by
calling fwrite(&struct, sizeof(struct). It's tempting to do, but it tends
to break code when you move from one compiler to another...
/*
* Shawn Hargreaves. Why is 'phonetic' spelt with a ph?
* Check out Allegro and FED on http://www.york.ac.uk/~slh100/
*/
- Raw text -