当我在 vc6 中使用 bison 和 flex 时,出现以下错误
lex.yy.c(395):错误 C2146:语法错误:缺少“;”在标识符“YY_PROTO”之前lex.yy.c(395) : fatal error C1004: 发现意外的文件结尾
这是什么原因造成的??请帮忙。
复制自评论:
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap YY_PROTO(( void ));
#else
extern int yywrap YY_PROTO(( void ));
#endif
#endif
YY_PROTO 宏仅支持旧的准标准 C,不支持原型(prototype)。今天你很难找到不支持它的编译器。这意味着作为第一个调试步骤,您可以尝试完全删除它,因为您想要使用原型(prototype),即将 lex.yy.c 修改为以下内容:
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap ( void );
#else
extern int yywrap ( void );
#endif
#endif
我知道 lex.yy.c 是一个生成的文件,所以这不是永久性的修复,但它至少应该确认问题与 YY_PROTO 的定义有关。
Tôi là một lập trình viên xuất sắc, rất giỏi!