www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/23/20:51:21

From: Delong <dandelong AT osha DOT igs DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Help: My structure members aren't getting the right offsets!
Date: Sun, 23 Feb 1997 19:27:55 -0500
Organization: ...
Lines: 41
Message-ID: <3310E089.78F9@osha.igs.net>
Reply-To: dandelong AT osha DOT igs DOT net
NNTP-Posting-Host: ttya0a.osha.igs.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I am trying to get the VBE implementation to return a VBEInfoBlock, and
VBEInfoBlock is supposed to be 512 bytes long, but the structure I
defined after the VBE 2.0 specs to have 512 bytes (I counted them) is
turning out to be 516 bytes long!

Here's the structure definition (I tried a 'typedef struct' too incase
it made a diff to the compiler, but no cigar).

struct VBEInfoBlock {
  char VBESignature[4]; //should be 'VESA', preset to 'VBE2'
  char VBEVersion_Minor,VBEVersion_Major;//major and minor version #
  char *OEMStringPtr;       
  char capabilities[4];
  short *videoModePtr;
  short totalMemory;
  short OEMSoftwareRev;
  char *OEMVendorNamePtr;
  char *OEMProductnamePtr;
  char *OEMProductRevPtr;
  char reserved[222];  //up to here, adds up to 256 bytes
  char OEMData[256];   //and then another 256 = 512
};


Now, if you count out each member it SHOULD add up to 512 bytes but the
compiler seems to be inserting spaces between certain members, the one I
found was betwee 'VBEVersion_Major' and 'OEMStringPtr' it is leaving 2
bytes between them ... why? I don't have optimizations turned on so it
should try to align the data to even offsets, should it?

I even made code that added up the 'sizeof' each element and got 512
bytes, please let me know if you know whats goind wrong here (since all
data after VBEVersion_Major is getting screwed, but before that it
works).

Thanks,
-- 
 ... Andrew Delong
______________________________________________________________
Check out my hompage ... Great for graphics & DOS programming
http://www.osha.igs.net/~dandelong/nash.htm

- Raw text -


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