Hi,
All other C compilers that I know of agree that n is a constant when
declared const. However, DEC C V5.2 says it is not.
The following alternatives are possible:
1. It is an error that I have to report to Digital.
2. It is optional and some obscure switch setting will make cc accept
the code.
3. It conforms to ANSI standard (and everybody else are sloppy having
n be a constant-expression when declared const int n = 7).
# cat p.c
main()
{
const int n = 10;
char s[n];
}
# cc -c p.c
cc: Error: p.c, line 4: In the declaration of "s", "n" is not
constant, but occurs in a context that requires a constant expression.
char s[n];
---------------^
#
Yours,
Lars Bro (lbro_at_dscc.dk)
Received on Fri Nov 21 1997 - 15:04:45 NZDT