This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Static const int as array bound inside class
- From: Torquil Macdonald Sørensen <torquil at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 28 Jun 2007 08:32:38 +0200
- Subject: Static const int as array bound inside class
Hello, it appears that g++-4.1 (or g++-4.2, Debian vers. 4.2-20070609-1) does
not support using a static const int as an array bound inside a class. I
wrote som example code below. This type of code is described in the
section "Compile-time constants inside classes" on page 295 in the
book "Thinking in C++" by Bruce Eckel from 1999. He warns that not all
compilers have implemented this feature. Is it planned for a later version of
g++?
Best regards,
Torquil Sørensen
/////////
Example code (from the book):
class X {
static const int size;
int array[size];
};
const int X::size = 100;
It gives the error message "array bound is not an integer constant"