[Bug c/62228] New: gcc : expected identifier before numeric constant

2014-08-22 Thread ankzzdev at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62228

Bug ID: 62228
   Summary: gcc : expected identifier before numeric constant
   Product: gcc
   Version: 4.1.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ankzzdev at gmail dot com

Created attachment 33379
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33379&action=edit
Header and C file used to reproduce this issue

I have attached the header file and c-code (t.c and t.h) used to reproduce this
issue.

# make t
cc t.c   -o t
t.c: In function 'main':
t.c:8: error: expected identifier before numeric constant
make: *** [t] Error 1

Error is due to this piece of code in multi-line macro.
#define LOG(module, level, msg) \
if ( (module)->level ) \
msg_log(msg)


While verifying the pre-processed output of the c-code:
# gcc -E t.c
...
int main()
{
struct logger module;
if ( (&module)->0 ) msg_log("Ooops\n");
return 0;
}
# cat t.c
#include 

#include "t.h"

int main()
{
struct logger module;
LOG(&module, 0, "Ooops\n");
return 0;
}


Here we can see the Macro LOG is wrongly getting interpreted. 
LOG(&module, 0, "Ooops\n"); ==> if ( (&module)->0 ) msg_log("Ooops\n");

This is happening as "level" in macro is getting replaced with a value "0".
Leading to the issue:  expected identifier before numeric constant


[Bug c/62228] gcc : expected identifier before numeric constant

2014-08-22 Thread ankzzdev at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62228

Ankzz  changed:

   What|Removed |Added

 CC||ankzzdev at gmail dot com
   Severity|normal  |major


[Bug c/62228] gcc : expected identifier before numeric constant

2014-08-22 Thread ankzzdev at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62228

--- Comment #2 from Ankzz  ---
Why do you think its not a bug?

It would be better if you can explain me the reason why level should be
replaced with a "0".

In the same macro if I replace "level" with "_level", 

#define LOG(module, level, msg) \
if ( (module)->_level ) \
msg_log(msg)

I get the pre-processed code as :

if ( (&module)->_level ) msg_log("Ooops\n");


[Bug c/62228] gcc : expected identifier before numeric constant

2014-08-22 Thread ankzzdev at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62228

Ankzz  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #3 from Ankzz  ---
(In reply to Marek Polacek from comment #1)
> Huh?  Why do you think it is a bug?

Got it ... Yup .. its not a bug. I would mark it resolved.