delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/19/09:45:21

Xref: news2.mv.net comp.os.msdos.djgpp:7627
From: hoodj AT topaz DOT cqu DOT edu DOT au (Adoxa)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: What am i doing wrong?
Date: 19 Aug 96 12:17:03 +1000
Organization: Cntrl Qld Uni., Aust.
Lines: 24
Message-ID: <1996Aug19.121703@topaz>
References: <199608181702 DOT AA28727 AT mail DOT umu DOT se>
NNTP-Posting-Host: topaz.cqu.edu.au
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <199608181702 DOT AA28727 AT mail DOT umu DOT se>, hubble AT hem DOT passagen DOT se (Andreas Vernersson) writes:
     <Removing blank lines>
> Could anyone explain this?
> typedef struct a
> {	unsigned int q2 __attribute__((packed));
> 	unsigned char qq __attribute__((packed));
> } b;
> typedef struct a2
> {	
> 	unsigned int q2;
> 	unsigned char qq;
> } b2;
> void main()
> {
> 	printf("size: %d\n",(int)sizeof(b));  // 5 ???
> 	printf("size: %d\n",(int)sizeof(b2));  // 8  ???
> }
> I only wants the datastructure to be 2+1=3 bytes... 

     Since djgpp is a 32-bit system, ints (and longs) are 32 bits, ie 4
     bytes. You should use short instead of int (or short int, but who
     types that? :) )

     Adoxa <hoodj AT topaz DOT cqu DOT edu DOT au>

- Raw text -


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