www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/07/15:24:45

Xref: news2.mv.net comp.os.msdos.djgpp:2520
From: avly AT castle DOT net (An)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: SIZEOF disparity...?
Date: Sun, 07 Apr 1996 04:05:15 GMT
Organization: The Castle Network, Internet Accounts 908 548-8881.
Lines: 49
Message-ID: <4k7f2a$ld7@arther.castle.net>
References: <Pine DOT A32 DOT 3 DOT 92 DOT 960406153743 DOT 75628A-100000 AT acs5 DOT acs DOT ucalgary DOT ca>
Reply-To: avly AT castle DOT net
NNTP-Posting-Host: bridge51.castle.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Alignment. Do:

#pragma pack(1)

struct ... {
  ... __attribute__((packed));
  ... -ditto-
};  

#pragma pack()

Mike <mbwarren AT acs DOT ucalgary DOT ca> wrote:

>what am i doing wrong:

>with djgpp v2, when i take the sizeof this struct:

>typedef struct
>{
>  char magic[2];
>  long size;
>  int dummy;
>  long offset;
>} header_t;

>it returns 16, when it should return 14 (2 chars = 2 + long (4) + int (4)
>+ lont (4) = 2+4+4+4=14)

>(BTW, why are int's represented as 4 bytes on a PC? sizeof(int) returns
>4...)

>i am using djgpp v2 on a 486-33 w/4megs ram...

>(if this is in the FAQ, sorry, but i can't use www/ftp; our DNS server is
>down...)



>------------.        mailto:mbwarren AT acs DOT ucalgary DOT ca          .--------------
>.___  ___.  |      o         _ |           ?                  |"a smoking
>|   \/   |  |	  /\,	  (*) '\o__        o                  | section in a
>|  i K E |  | .(*)>(*)______'(*)\_____./'\.|\_________.       | resturant is
>|        |  | | Gateway to the    TEMPLE OF MIKE      +---+   | like a peeing
>|__|\/|__|  | `-.----------------------------------.--'   |   | section in a
>w a r r e n |   | http://www.ucalgary.ca/~mbwarren +------+   | swimming pool"
>------------'   `----------------------------------'          '\.____________



- Raw text -


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