K
Kyle Blake
I am writing a parser using flex & bison, however this appears to be a C
problem.
GCC gives the following error:
error: request for member file in something not a structure or union
The offending structure is declared as:
typedef struct YYLTYPE
{
int fl;
int fc;
int ll;
int lc;
char* file;
} YYLTYPE;
/* Apparently, bison wants it to be a macro */
#define YYLTYPE YYLTYPE
The reference that caused the error is the expansion of the following macro,
an adaption of the default one provided with bison:
#define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
(Current).fl = YYRHSLOC(Rhs, 1).fl; \
(Current).fc = YYRHSLOC(Rhs, 1).fc; \
(Current).ll = YYRHSLOC(Rhs, N).ll; \
(Current).lc = YYRHSLOC(Rhs, N).lc; \
(Current).file = YYRHCLOC(Rhs, 1).file; \
} \
else \
{ \
(Current).fl = (Current).ll = \
YYRHSLOC(Rhs, 0).ll; \
(Current).fc = (Current).lc = \
YYRHSLOC(Rhs, 0).lc; \
(Current).file = YYRHSLOC(Rhs, 0).file; \
} \
while (0)
Current, YYRHCLOC(Rhs, 1), and YYRHCLOC(Rhs, N) are all of type YYLTYPE.
None of them are pointers.
It compiles fine if I comment out the line:
(Current).file = YYRHCLOC(Rhs, 1).file;
Even though file is still referenced in the else block.
Any ideas?
problem.
GCC gives the following error:
error: request for member file in something not a structure or union
The offending structure is declared as:
typedef struct YYLTYPE
{
int fl;
int fc;
int ll;
int lc;
char* file;
} YYLTYPE;
/* Apparently, bison wants it to be a macro */
#define YYLTYPE YYLTYPE
The reference that caused the error is the expansion of the following macro,
an adaption of the default one provided with bison:
#define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
(Current).fl = YYRHSLOC(Rhs, 1).fl; \
(Current).fc = YYRHSLOC(Rhs, 1).fc; \
(Current).ll = YYRHSLOC(Rhs, N).ll; \
(Current).lc = YYRHSLOC(Rhs, N).lc; \
(Current).file = YYRHCLOC(Rhs, 1).file; \
} \
else \
{ \
(Current).fl = (Current).ll = \
YYRHSLOC(Rhs, 0).ll; \
(Current).fc = (Current).lc = \
YYRHSLOC(Rhs, 0).lc; \
(Current).file = YYRHSLOC(Rhs, 0).file; \
} \
while (0)
Current, YYRHCLOC(Rhs, 1), and YYRHCLOC(Rhs, N) are all of type YYLTYPE.
None of them are pointers.
It compiles fine if I comment out the line:
(Current).file = YYRHCLOC(Rhs, 1).file;
Even though file is still referenced in the else block.
Any ideas?