A
Amandil
Hi all. Now I'm getting back on topic 
I tried to use a const instead of a #define, and to my surprise, I
couldn't. Here is the code snippet:
const int CONST = 10;
char str[CONST];
The error I got (with gcc 3.4.2 on mingw) was:
assemble.c:25: error: variable-size type declared outside of any
function
Checking the C standard, str[] must be declared (at file scope) with
an integer constant expression. It seems that my declaration of CONST
does not fall into that category, though, of course, had I used a
#define CONST 10
I would have no trouble. It took me a couple of minutes to get the
idea that a const variable is not a constant expression. Is that the
case? Just want to make sure I got it right.
-- Marty Amandil (peeping through the periscope: is the coast clear?)
I tried to use a const instead of a #define, and to my surprise, I
couldn't. Here is the code snippet:
const int CONST = 10;
char str[CONST];
The error I got (with gcc 3.4.2 on mingw) was:
assemble.c:25: error: variable-size type declared outside of any
function
Checking the C standard, str[] must be declared (at file scope) with
an integer constant expression. It seems that my declaration of CONST
does not fall into that category, though, of course, had I used a
#define CONST 10
I would have no trouble. It took me a couple of minutes to get the
idea that a const variable is not a constant expression. Is that the
case? Just want to make sure I got it right.
-- Marty Amandil (peeping through the periscope: is the coast clear?)