Mail Archives: djgpp/1999/01/11/15:46:45
From: | Henno Vermeulen <Vermeulen AT regiolicht DOT nl>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Char-in-struct bug!?
|
Date: | Mon, 11 Jan 1999 21:44:33 +0100
|
Organization: | Casema Internet
|
Lines: | 30
|
Message-ID: | <369A62B1.5D936926@regiolicht.nl>
|
NNTP-Posting-Host: | host068.regiolicht.nl
|
Mime-Version: | 1.0
|
X-Trace: | news.casema.net 916087476 13332 195.212.41.68 (11 Jan 1999 20:44:36 GMT)
|
X-Complaints-To: | abuse AT casema DOT net
|
NNTP-Posting-Date: | 11 Jan 1999 20:44:36 GMT
|
X-Mailer: | Mozilla 4.5 [nl] (Win98; I)
|
X-Accept-Language: | nl
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
I found out, that when you use a struct with djgpp (both in .c and .cpp
files) like this:
typedef struct {
char x, y, z;
} my_type1;
the size will be 3 bytes, but when you have one like this:
typedef struct {
char x, y, z;
int i;
} my_type2;
the size will be 8 bytes, even if I remove y or y and z. When I add a
char behind i, the size will grow to 12 bytes! When using short ints, I
get the same problem.
Is this some kind of dword/long int aligning? Or is it a bug?
I found this strange thing when I made a structure containing a .bmp
header, which uses as the first two bytes, the chars 'B' and 'M'.
Compiling with turbo c++ 3.0 gives a (correct) structure size of 54, but
compiling with djgpp gives a size of 56 (2 zero chars are added after
the first two).
If this is not a bug, how can I correct this?
Henno Vermeulen.
- Raw text -