www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/03/24/05:49:07

From: "WODRICH, M, M, WDRMAR002" <MWODRICH AT eleceng DOT uct DOT ac DOT za>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Date: Fri, 24 Mar 1995 11:06:26 SAST
Subject: Sizeof structure different in DJGPP?

Hello

I seem to come up with a new question every day almost, but here goes!
I have a structure as follows in my program :

struct something
{
   char ch;
   unsigned short int number;
};

In Turbo-C the sizeof this struct is, as expected, 3 bytes. In DJGPP 
it is 4 bytes ???! The sizeof (char) and sizeof (unsigned short int) 
is 1 & 2 respectively in both compilers... Does DJGPP Word-align data,
promoting the 3-byte strucure to 4 bytes? The reason I am asking is 
that I want to store many (60,000) such structs in an array, and 
wasting 60Kb+ in DJGPP seems crazy, even though memory is no problem. 
I want to avoid paging on small systems unless absolutely 
neccessary (sp?), so the extra 1 byte is irritating me...

Thanks for an informative mailing list!
Mark.--

Mark Wodrich                Email : mwodrich AT eleceng DOT uct DOT ac DOT za
13 Letchworth Road
Pinelands                   " Excuse me, but I think your karma has
7405                          just run over my dogma ..."

- Raw text -


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