开发者

Bison/Yacc: yyparse not declared in this scope

开发者 https://www.devze.com 2023-03-18 06:43 出处:网络
This question is similar to this one but for yyparse, not yylex. I\'ve been battling with this for hours now!I\'m wanting to call yyparse from a C program (actually a C++ one but I ended up using the

This question is similar to this one but for yyparse, not yylex.

I've been battling with this for hours now! I'm wanting to call yyparse from a C program (actually a C++ one but I ended up using the old flex/bison rather than the newer ones for C++ woops (didn't realise the C++ versions even existed)). The only error is that 'yyparse' was not declared in this scope. I've tried defining the variable as global but it doesn't seem to work.

In the Flex file I tried:

extern "C" {
  int yyparse();
}

and this in the Bison file:

extern int yyparse();

but it didn't do anything.

So.. I think I'm linking wrong. The problem 开发者_如何学Cis that I am using Qt which builds the make file automatically so I can't edit it without it just being overritten again. Is there any way of fixing the problem without changing the linking? If not, how is the linking meant to be done?


The yyparse declaration should go in a header included by the C++ file that calls yyparse, rather than the flex or bison files, since the C++ file is the one that needs the declaration. bison will create the declarations it needs within the source file it generates.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号