Bison yacc and lex issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All

I have defined a macro as follows
#define XFILENAME_P(text_name) static const char *x_p=text_name;\
static const char *_x_p={"@(#)" " " \
__DATE__ " " __TIME__ " " __FILE__ ":" text_name}

When the above is used in code, and no reference is made to either x_p or _x_p., gcc gives a warning that x_p is defined but not used. Which is understandable. Now to clear this warning ( I do not want to turn off warnings and would like to clean code so that with warnings flag on, gcc should not give 
any warnings), what I did was :

#define XFILENAME_P(text_name) static const char *x_p=text_name;\
static const char *_x_p={"@(#)" " " \
__DATE__ " " __TIME__ " " __FILE__ ":" text_name}; \
_x_p=_x_p; x_p=x_p

Please note that there is no ";" at the end. This is so because the macro is called as XFILENAME_P("sample"); in the code. But that aside, when the above "correction" is made, and this change is put in a yacc .y file and yacc -vd is run against that file and the subsequent y.tab.c file is moved to a .c file and using gcc is compiled. gcc gives the following

error: conflicting types for _x_p
error: previous definition of  _x_p was here
error: conflicting types of x_p
error: previous definition of x_p was here

Any ideas as to what this might be? Any help would be greatly appreciated.

Thanks in advance

With Regards

Vardhan



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux