3
votes

I am currently using flex/bison to generate a lexer & parser, with the whole project in Xcode. However the files generated by flex & bison produce a couple of compiler warnings when they are compiled. How can I suppress these warnings?

I know I can suppress warnings on a per-file basis through the 'Build Phases' tab, but the generated files don't appear here.

I tried adding the flag [-w] to the source file [ie, the .lpp and .ypp files], however this didn't work - Xcode understandably tried to pass that flag to bison, which it didn't like.

1
If the warnings are related to unused functions in the scanner, you can suppress them with appropriate flex options. There are also some signed/unsigned compare warngins, many of which can be eliminated by upgrading (but not all, yet).rici

1 Answers

3
votes

You can also turn off the warnings by embedding a pragma for the clang (or gcc) compiler to disable individual warnings.

For example, you could do the following a .lpp or .ypp file:

%{
#pragma clang diagnostic ignored "-Wunused-variable"
%}
...
%%
...

Where the %{ ... %} construct tells flex/bison to pass the line direct to the output.


References:

  1. Disabling clang warnings
  2. Selectively disabling gcc warnings