This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc preprocessor bug ?
- From: Nilmoni Deb <ndeb at ece dot cmu dot edu>
- To: Neil Booth <neil at daikokuya dot co dot uk>
- Cc: bug-gcc at gnu dot org
- Date: Thu, 10 Apr 2003 01:49:47 -0400 (EDT)
- Subject: Re: gcc preprocessor bug ?
On Thu, 10 Apr 2003, Neil Booth wrote:
> Nilmoni Deb wrote:-
>
> >
> > Hi,
> > I compiled the following program with both gcc-2.95.3 and
> > gcc-3.2.1 and in both cases it compiled ok and ran ok (printed "i=10").
> >
> > #include<stdio.h>
> >
> > #define MAX 10;
> >
> > main()
> > {
> > int i=MAX;
> > printf("i=%d\n", i);
> >
> > /* int *j=0;
> > j = (int*)malloc(MAX*sizeof(int)); */
> > }
> >
> > Now, if I uncomment the last two lines, then the compiler gives the error:
> > file.c:11: parse error before ';' token
> >
> > Now, if I remove the ";" from the #define statement, it compiles ok.
> >
> > Shouldn't the preprocessor always give an error for a #define statement
> > ending in ";" ? It seems it does not do so consistently.
>
> I think you're confused by what the preprocessor does and what the
> compiler does.
Not quite. I just used the term compiler in a more inclusive way.
Anyway, its obvious that the preprocessor is probably substituting "10;"
for MAX everywhere so that line 11 is getting an error later from the
compiler. Would it be too much to expect the preprocessor to handle it
more wisely ?
>
> Neil.
>