This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bug in gcc



  > 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>







Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]