使用 g++ 编译 lex.yy.c 时出错

发布于 2024-12-26 02:21:01 字数 783 浏览 3 评论 0原文

我写了一个 bison、flex 和 c++ 文件。 bisoon和flex的编译通过了。但是当我尝试编译 c 和 cpp 文件时:
g++ *.cpp *.c,我收到奇怪的错误: lex.yy.c:479: 错误:预期为“;”在“静态”之前 当我打开 lex.yy.c 文件时,我看到由 flex 自动创建的代码。这是第 479 行左右的代码部分,第 479 行是粗体:

using namespace std;
using namespace output
#line 465 "lex.yy.c"

/* Macros after this point can all be overridden by user definitions in
 * section 1.
 */

#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap YY_PROTO(( void ));
#else
extern int yywrap YY_PROTO(( void ));
#endif
#endif

#ifndef YY_NO_UNPUT

static void yyunput YY_PROTO(( int c, char *buf_ptr )); #endif

#ifndef yytext_ptr
static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
#endif

我不知道该怎么办。请帮我。

谢谢

i have written a bison, flex and c++ files.
Compilation of bisoon and flex was passed. But when i'm trying to compile the c and cpp files:
g++ *.cpp *.c, i get strange error:
lex.yy.c:479: error: expected `;' before "static"
and when i opened lex.yy.c file, i see code that was automatically created by flex. This is some part of code around line 479, line 479 is bold:

using namespace std;
using namespace output
#line 465 "lex.yy.c"

/* Macros after this point can all be overridden by user definitions in
 * section 1.
 */

#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap YY_PROTO(( void ));
#else
extern int yywrap YY_PROTO(( void ));
#endif
#endif

#ifndef YY_NO_UNPUT

static void yyunput YY_PROTO(( int c, char *buf_ptr ));
#endif

#ifndef yytext_ptr
static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
#endif

i don't have any idea what to do. Please help me.

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

゛清羽墨安 2025-01-02 02:21:01

您不应该尝试修复 lex 生成的文件中的错误,而是需要检查 lex 规范是否有错误。

更新:

寻找此类错误来源的可能位置是 lex 规范用户代码部分。正如注释中所指出的,LEX 不会检查它根据规范生成的代码。

You should`t try to fix the error in file generated by lex, instead of it you need to check your lex specification for errors.

UPDATE:

Possible place to look for source of such mistake is lex specification user code section. As it is noticed in comments, LEX isn`t checking code that it generates from the specification.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文