Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!husc6!seismo!ll-xn!cit-vax!news From: news@cit-vax.UUCP Newsgroups: comp.lang.c++ Subject: Variable constants Message-ID: <2032@cit-vax.Caltech.Edu> Date: Fri, 13-Mar-87 09:31:21 EST Article-I.D.: cit-vax.2032 Posted: Fri Mar 13 09:31:21 1987 Date-Received: Sat, 14-Mar-87 10:49:31 EST Reply-To: jon@oddhack.UUCP (Jon Leech) Organization: California Institute of Technology Lines: 43 Organization : California Institute of Technology Keywords: From: jon@oddhack.Caltech.Edu (Jon Leech) Path: oddhack!jon While writing some C++ code which was intended to call FORTRAN routines, I was using constant-dimensioned matrices. The logical thing to do, then, was const int n = 20; double m[n][n]; The FORTRAN routines wanted the matrix and the dimension of the matrix passed, along with 6 other parameters. Initially I didn't feel like templating the routine (pretty difficult to do correctly anyway, given that FORTRAN does not distinguish between array dimensions), so I just had: extern void foo(...); foo(m, &n, etc...); All fine and dandy. Now I decide to add a new array, declared AFTER the subroutine call: double x[n]; Oops! The enlightening error message 'error: cannot evaluate constant' occurs. This was most confusing. After I bit I decided this meant cfront thought that 'n' might be modified within 'foo'. OK, so I proceeded to template the function: extern void foo(double m[n][n], const int *pc, etc...); Unfortunately, the same error message still occurred (this is 1.1, incidentally). I consider this a bug. The template is clearly specifying that whatever is passed is not being modified, yet cfront appears to believe this anyway. Perhaps Bjarne would care to comment? ``Fixed in 1.2'', or must I work around it, or am I just missing something obvious (it is 6:30 AM, after all)? -- Jon Leech (jon@csvax.caltech.edu || ...seismo!cit-vax!jon) Caltech Computer Science Graphics Group __@/