delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/14/10:12:14

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP inconsistencies?
Date: 14 Mar 1997 09:45:08 GMT
Organization: The National Capital FreeNet
Lines: 49
Message-ID: <5gb6n4$heh@freenet-news.carleton.ca>
References: <5g7p5i$abl AT netra DOT montana DOT edu>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet3.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Paul Peavyhouse (pv AT cs DOT montana DOT edu) writes:
>         I have noticed a few inconsistencies with the DJGPP compiler over 
> other C compilers I use.
>         The first one is that the lines:
> 
>         for(int i=0; i<256; i++)
>         {       someFunction(i);
>         }

This is specific to C++. Some compilers might allow it also in C, most
probably do  not. DJGPP is among them. When this compiles, I would guess
you have compiled a .cc or .cpp file, and when it does not, a .c.

>         int i;
>         for (i=0; i<256; i++)
>         {       someFunction(i);
>         }
> 
>         works everytime...why?

This works in C or C++. The former is only ansi in C++. Some compilers
allow it in C I guess, just as some (this time including djgpp v2, but not
v1) allow the // style comment in vanilla c.
These compilers are probably dual like gcc and just blur the distinctions
by using the same preprocessor, which then strips /**/ and // comments
regardless, and by not distinguishing the two in the matter of putting
variable declarations among executable code.

>         Also, I sometimes get random compiler "parse" errors when I include 
> the following code in a program:
> 
>         char *str;
>         if ( (str = getenv("DEM_PATH")) == NULL) {
>                 printf("\"DEM_PATH\" environment variable not set\n");
>                 exit(1);
>         }

Only thing that might cause an error is if you don't #include one of the
headers that defines null. Try adding this at the top then:

#ifndef NULL
#define NULL 0
#endif
--
    .*.  Where feelings are concerned, answers are rarely simple [GeneDeWeese]
 -()  <  When I go to the theater, I always go straight to the "bag and mix"
    `*'  bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh

- Raw text -


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