delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/08/07:02:42

From: "Alan Wills" <alan AT spd DOT eee DOT strath DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: annoying structure problem
Date: Thu, 8 Jul 1999 11:20:13 +0100
Organization: University of Strathclyde Computer Centre
Lines: 26
Message-ID: <7m1u1e$pnu$1@rockall.cc.strath.ac.uk>
NNTP-Posting-Host: dolphin.eee.strath.ac.uk
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I have to read in this structure into a program.  The problem is, the
compiler returns its size as 16 bytes when it should be 14 bytes.  If I
change all the variables to unsigned short int then it gives 10 bytes (as it
should be).  If I change the 2nd variable to unsigned short int it gives 12
bytes (as it should be).  But, if I change the last variable to unsigned
short int it gives 16 bytes as the total space occupied.  Just what is going
on here?

typedef struct
{
 unsigned short int   bfType;
 unsigned int            bfSize;
 unsigned short int   bfReserved1;
 unsigned short int   bfReserved2;
 unsigned int            bfOffBits;
}BITMAPFILEHEADER;

Thanks,
--
Alan
____________________________________
Alan Wills
alan AT spd DOT eee DOT strath DOT ac DOT uk



- Raw text -


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