const in array bound expression
Preston Gardner
preston at peritus.UUCP
Tue Aug 2 08:08:20 AEST 1988
What constitutes a constant expression under the new ANSI standard? The
following should be legal:
const int i = 5;
int a[i];
But what about this? This offers a big opportunity for headaches.
const int agg[] = { 1, 1, 2, 3, 5, 8, 13, 21, 34 };
int a[agg[4]];
I could not find anything in the ANSI draft I have (May 13, 1988) to help
with this.
C++ allows the first case but the AT&T C++ preprocessor we have rejects
the second.
Does anybody out there have any experience with this? I believe the correct
thing is to allow scalar const vars (whose value is known in this module --
not externs) to be used in array bound expressions. But I don't see it
in the ANSI standard, and I don't have any ANSI standard compilers (except the
one I'm writing) to try it out on right now.
--
-- Preston Gardner
Peritus International, Inc.
..{pyramid,sun}!oliveb!peritus!preston
More information about the Comp.lang.c
mailing list