Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!oliveb!peritus!preston From: preston@peritus.UUCP (Preston Gardner) Newsgroups: comp.lang.c Subject: const in array bound expression Keywords: const ANSI constant expression array Message-ID: <123@peritus.UUCP> Date: 1 Aug 88 22:08:20 GMT Organization: Peritus International, 10201 Torre, Cupertino, CA. Lines: 26 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