This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Bug in gcc
- To: Nilmoni Deb <ndeb at ece dot cmu dot edu>
- Subject: Re: Bug in gcc
- From: Mo McKinlay <mmckinlay at gnu dot org>
- Date: Sat, 26 Aug 2000 01:36:10 +0100 (BST)
- cc: Mo McKinlay <mmckinlay at gnu dot org>, bug-gcc at gnu dot org
- Organization: inter/open Labs
> I tried exactly that:
>
> int NOM_CURVATURE = 35;
> #define NOM_CURVATURE 36
>
>
> and it is still not giving an error.
>
> Program execution shows the value of NOM_CURVATURE as 36.
No, you're missing the point.
The #define defines a _preprocessor macro_. Preprocessor macros are
interpreted before the program itself is compiled. If you have the
following:
int NOM_CURVATURE = 35;
#define NOM_CURVATURE 36
printf("%d\n", NOM_CURVATURE);
The preprocessor would interpret the macro and produce the following for
compilation:
int NOM_CURVATURE = 35;
printf("%d\n", 36);
Unless you #undef NOM_CURVATURE to undefine the macro, any further
references to NOM_CURVATURE will be replaced with 36 by the
preprocessor, and your variable will never be referenced.
--
Mo McKinlay Chief Software Architect inter/open Labs
-------------------------------------------------------------------------
GnuPG Key: pub 1024D/76A275F9 2000-07-22 Mo McKinlay <mmckinlay@gnu.org>