www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/11/12:46:15

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Bytes and words
Date: Wed, 11 Feb 1998 09:13:05 -0800
Organization: Alcyone Systems
Lines: 40
Message-ID: <34E1DC21.598363AF@alcyone.com>
References: <34DD3806 DOT 92C44AF4 AT ea DOT oac DOT uci DOT edu>
NNTP-Posting-Host: 165.90.20.242
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Jason Alexander wrote:

> typedef struct _TgaHeader
> {
>  BYTE IDLength;
>  BYTE ColorMapType;
>  BYTE ImageType;
>  WORD CMapStart;
>  WORD CMapLength;
>  BYTE CMapDepth;
>  BYTE XOffSet;
>  WORD YOffSet;
>  WORD Width;
>  WORD Height;
>  BYTE PixelDepth;
>  BYTE ImageDescriptor
> } TGAHEAD;
> 
>   If I try to include this in a simple program, gcc complains about
> the
> use of semicolons in a structure and (it seems) about the use of
> 'BYTE'.  Is the above just meant to be a very formal looking piece of
> pseudocode, or can one actually declare bytes and words (2 bytes?) in
> this manner?

It's meant to be pseudocode.

It's also a pretty stupid thing to put in a book, since there is no way
in standard C to guarantee that all structure members are unpadded
(e.g., that there is no unused space between the members).  In gcc/DJGPP
you do this with the use of the __attribute__ keyword; see C extensions
in the info pages.

-- 
         Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
                       Alcyone Systems / http://www.alcyone.com/max/
  San Jose, California, United States / icbm://+37.20.07/-121.53.38
                                     \
                       "Life may be / the product of imperfections."
                                   / (Marclo Gleiser)

- Raw text -


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