[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: 'size_t' undeclared (first use in this function)
From: |
Tom Wang A |
Subject: |
RE: 'size_t' undeclared (first use in this function) |
Date: |
Fri, 24 Jul 2015 09:58:51 +0000 |
Thanks very much!
In my system, YYSIZE_T is always defined as __SIZE_TYPE__ in the output
file(y.tab.c .*), which are compiled by bison 2.1 and bison 2.3. And
__SIZE_TYPE__ is actually a 8-byte size type on the server.
And I find another way to resolve my problem: If I remove the line
#define YYERROR_VERBOSE 0
in the input file (some .yacc file) of bison, then this line will be also
removed in the output file, size_t will be defined at this time, so
YYERROR_VERBOSE here generates a magic logic for size_t reference. Even I
define it as 0 in the input file, it will be re-defined automatically as 1, by
bison .
Why I add this line in the input file? I wanted to collect some verbose error
messages, so defined YYERROR_VERBOSE as 1 at first, and then re-defined it as
0, thought to disable the function. Forgive me...
-----Original Message-----
From: Hans Aberg [mailto:address@hidden
Sent: Thursday, July 23, 2015 5:55 AM
To: Tom Wang A
Cc: address@hidden
Subject: Re: 'size_t' undeclared (first use in this function)
> On 22 Jul 2015, at 11:17, Tom Wang A <address@hidden> wrote:
>
> I encounter a compiling error with bison 2.1. The output file y.tab.c cannot
> pass gcc compiling, while there is no such problem on bison 2.3. However, the
> linux server which installed bison 2.1 cannot be upgraded with bison 2.3 for
> some reason. So my question is, how can I avoid such error with bison 2.1?
> The error is showed as:
Only the last version is supported, and a number of other bugs have been fixed,
so it is best to find a way to upgrade. Can’t you install it in the user
account?
> y.tab.c: In function 'yytnamerr':
> y.tab.c:718: error: 'size_t' undeclared (first use in this function)
There is a typo: it should be YYSIZE_T instead of size_t, at least it is what
Bison 2.3 outputs. And size_t is in <stdio.h>. You might preprocess the file
and see what YYSIZE_T is defined to.