www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/10/11:42:24

Xref: news2.mv.net comp.os.msdos.djgpp:8477
From: aron AT wallaker DOT torolab DOT ibm DOT com (Aron Wallaker)
Newsgroups: comp.os.msdos.djgpp
Subject: Problem with #define's under DJGPP
Date: 9 Sep 1996 15:05:21 GMT
Organization: IBM Microelectronics Division
Lines: 39
Message-ID: <511bnh$nne@tornews.torolab.ibm.com>
Reply-To: wallaker AT vnet DOT ibm DOT com
NNTP-Posting-Host: wallaker.torolab.ibm.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I'm having a problem trying to use #define's in a header file to define
constants for use in my C code. Here's an example:

--File:STAR.H---------------------

#define  STARPOPULATION    0x200

--FILE:STAR.C---------------------
#include"star.h"

void main(void)
{
   int LocalStarPop = STARPOPULATION;  // This works.

   for(x=0;x < STARPOPULATION ; x++)   // This doesn't, see below.
   {
       //whatever
   }
}

When I try to set a local variable to the value I have #define'd in the
header file, it seems to work fine. However, if I try to use the #define
value in a function call, or a structure such as the for(... above, I
get a "parsing error in line...." error. I checked the FAQ's I could find,
and I saw no mention of this behavior. I have DJGPP V2.0 which I dl'd off
simtel about 2 weeks back. Does this look familiar to anyone ? I use this
type of #define all the time in Watcom, so I'd be pretty dissapointed if
I couldn't do something similar under DJGPP. I tried searching for any
command-line parameters which might affect the preprocessor and how it
handles #define's but I didn't find any. I would appreciate any feedback
anyone could give me.

Thanks,

-Aron
--
Aron Wallaker            IBM Microelectronics Development Lab
wallaker AT vnet DOT ibm DOT com    Toronto, Ontario
These are my opinions-IBM has its own

- Raw text -


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