paul@cacilj.UUCP (Paul Close) (12/22/89)
That's the error I get: "initializer for static variable is not constant". This is gcc version 1.36 on a sun-3 running SunOS-4.0.3. It doesn't work any better on other machines. Here's the code: test.c: ================ struct {const long t_hdr; const char t6[7];} T_473={0x17000006,"INSERT"}; struct {const long e_hdr; const long e[5];} E_473={0x19000000,0x00000000, T_473.t6[0],0x00000000,0x00000000,0x00008000}; ================ ^^^^^^^^^^^---- Here's what gcc complains about, line 4. here's a transcript: % gcc -v -c -traditional test.c gcc version 1.36 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 test.c /usr/tmp/cca14501.cpp GNU CPP version 1.36 /usr/local/lib/gcc-cc1 /usr/tmp/cca14501.cpp -quiet -dumpbase test.c -version -o /usr/tmp/cca14501.s GNU C version 1.36 (68k, MIT syntax) compiled by GNU C version 1.36. default target switches: -m68020 -mc68020 -m68881 -mbitfield test.c:4: initializer for static variable is not constant This code works fine using pcc, but not even gcc -traditional will compile it (without the 'const', of course). I've seen this with other ANSI compilers, too. The error message is clear enough, but I have a real need to do this, and under pcc it worked fine. How can I make a large, static (and constant), linked table using portable C constructs? -- Paul Close paul@cacilj.CTS.COM ...!{uunet, ucsd, crash}!cacilj!paul The Obi-wan Kenobi method: "Use the Source, Luke" -Jim Fulton