From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,bc745b8412f53f25 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-03-07 07:10:58 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!zeus.visi.com!news-out.visi.com!green.octanews.net!news-out.octanews.net!news.glorb.com!newsgate.cistron.nl!news.cambrium.nl!news.cambrium.nl!humbolt.nl.linux.org!news.nl.linux.org!surfnet.nl!news-stob.telia.net!telia.net!217.209.241.173.MISMATCH!masternews.telia.net.!newsc.telia.net.POSTED!not-for-mail From: =?ISO-8859-1?Q?Bj=F6rn_Persson?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031114 X-Accept-Language: sv, en-us MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Error-names. References: <5tibh1-m92.ln1@martinkl.dialup.fu-berlin.de> In-Reply-To: <5tibh1-m92.ln1@martinkl.dialup.fu-berlin.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Message-ID: <3YG2c.85332$dP1.238856@newsc.telia.net> Date: Sun, 07 Mar 2004 15:10:55 GMT NNTP-Posting-Host: 217.209.116.179 X-Complaints-To: abuse@telia.com X-Trace: newsc.telia.net 1078672255 217.209.116.179 (Sun, 07 Mar 2004 16:10:55 CET) NNTP-Posting-Date: Sun, 07 Mar 2004 16:10:55 CET Organization: Telia Internet Xref: archiver1.google.com comp.lang.ada:6121 Date: 2004-03-07T15:10:55+00:00 List-Id: Martin Klaiber wrote: > BTW: does someone know why these constants are not recognized by the > C-program as constants? They are declared as constants and in the C > header-file I put: >=20 > /* error-codes */ >=20 > extern const int no_error_code; > extern const int general_error_code; > ... >=20 > But if I want to use it in a switch-command like that: >=20 > int year; > ... > for (year =3D 2003; year <=3D 2005; ++year) { > switch (set_year (year)) { > case no_error_code : > set_lzz (1); > ... > =20 > the compiler says: >=20 > test_c.c:20: case label does not reduce to an integer constant >=20 > Is my exporting wrong? Or is this a C-problem? When I use "case 0" > instead of "case no_error_code" it works ok, but this is what I want > to avoid. As I understand it, "const" in C doesn't give you a constant. You get=20 kind of a read-only variable. You can't change its value, but it's still = treated as a variable and not allowed where a constant is required. Put another way, where the language requires a constant it actually=20 requires a literal, not a named constant. I suppose this is why everyone uses preprocessor macros for constants,=20 since they are translated to literals. Yet another reason to loathe C ... --=20 Bj=F6rn Persson jor ers @sv ge. b n_p son eri nu