Mail Archives: djgpp/1997/03/13/21:27:23
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 -