www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/10/24/19:34:50

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: source code help
Date: Thu, 24 Oct 1996 18:56:38 -0700
Organization: Three pounds of chaos and a pinch of salt
Lines: 31
Message-ID: <32701E56.6893@cs.com>
References: <326EBDEE DOT 4ED AT iamerica DOT net>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp211.cs.com
Mime-Version: 1.0
To: Jon Slaughter <lobo AT iamerica DOT net>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Jon Slaughter wrote:
> 
> here is some code that is supose to read the boot sector and print out
> all the information in BOOT_RECORD. But for some reason, it doesn't :( I
> have no idea why. It would seem that I left some variable out of the
> structure because the first two are ok, but I've looked over it and
> couldn't find anything wrong. It also could be the strings since I have
> no idea of how c handles them(except that they are null terminated)...
> Its probably something stupid, but if anyone can help me, please!!

Under GCC, all struct members are 32-bit aligned.  You have to pack the
structure by placing "__attribute__ ((packed))" between the final brace
and the terminating semicolon, like so:

struct struct BOOT_RECORD_STRUCT {
        BYTE jump[3];
        ...
        BYTE filler[500];
} __attribute__ ((packed));

For additional details, please read the v2 FAQ (v2/faq202b.zip),
sections 22.9 and 22.10, as well as the docs for gcc under C
Extensions|Type Attributes.  (command line:  info gcc "c ext" "type
att")

-- 
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I |        fighteer AT cs DOT com          |
| Proud owner of what might one   |   http://www.cs.com/fighteer    |
| day be a spectacular MUD...     | Plan: To make Bill Gates suffer |
---------------------------------------------------------------------

- Raw text -


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