delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/13/21:27:23

Date: Thu, 13 Mar 1997 19:17:08 -0700 (MST)
From: David May <dmay AT tvi DOT cc DOT nm DOT us>
To: Paul Peavyhouse <pv AT cs DOT montana DOT edu>
cc: djgpp AT delorie DOT com
Subject: Re: DJGPP inconsistencies?
In-Reply-To: <5g9pat$fac@netra.montana.edu>
Message-ID: <Pine.GSO.3.96.970313185811.18652A-100000@curie.tvi.cc.nm.us>
MIME-Version: 1.0

On Thu, 13 Mar 1997, Paul Peavyhouse wrote:

> if ( (str = getenv("DEM_PATH")) == NULL) {
>     printf("'DEM_PATH' environment variable not set\n");
>     exit(1);
> }
> BITMAP *buffer;         <-- Parse error on THIS line
> 
>         If I move BITMAP *buffer before the "if" statement, the compiler is 
> all happy...WHY?  Thanks anyway for the reply.
> 
>                                                                         PV

Because this is C, not C++. I suggest you get the C FAQ and read it.  It
will tell you what is ANSI C, not C compiler extensions.  If you meant
to compile C++, you should rename the extension to .cc (or on the command
line, tell gcc to compile it as a .C - capital C - file).

On reading what I just wrote, I can see that it is not real clear.  I'm
assuming that you mean to write C code, but are used to Borland C++,
where the compiler is set to compile C++ always, or have a compiler that
allows you to declare variables anywhere in the code that C++ would allow.
Allowing facilities that are not part ANSI are called extensions to the
language.  gcc determines how it will compile the source based on the file
extension.  A program with an extension of .c is a C program; one with an
extension of .cc, .cpp, .cxx, or .C is considered a C++ program.

Hope this helps.

David May
ID Card Administrator
Albuquerque TVI

- Raw text -


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