开发者

Bison/Yacc: yyparse not declared in this scope

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜