Re: implicit declaration of function 'yylex' is invalid in C99

Akim Demaille <[email protected]> Sat, 15 Jan 2022 17:02:07 +0100
Newsgroups gmane.comp.parsers.bison.bugs
Message-ID <[email protected]>
Ryan,

> Le 15 janv. 2022 à 11:04, Ryan Schmidt <[email protected]> a écrit :
> 
> On Jan 15, 2022, at 03:57, Akim Demaille wrote:
> 
>> I personally feel that generating these prototypes automatically is actually more complex (for the user, not for Bison) than merely specifying them.
> 
> Ok. Can you provide any guidance for how to specify them?
> 
> I am a maintainer of packages within the MacPorts package management system.

And I thank you a lot for the effort you put into the MacPorts.

> I've encountered many of our ports that fail to build for this reason, and I haven't known how to fix them. For other implicit declaration of function problems it's usually been a simple matter of including a missing header or writing a function prototype, but with bison/flex, there isn't a .c or .h file into which such a prototype could be inserted, and even if I knew what file to insert it into, I wouldn't know what prototype to write.

It very much depends on the *.l and the *.y files.  But most of the time it suffices to include something like

%code provides {
  int yylex (void);
  void yyerror (const char *);
}

in the first part of the *.y file (before %%).

If you provide me with pointers to these packages, I can help finding the appropriate fixes.