3

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.

splash
  • 13,037
  • 1
  • 44
  • 67
Tom H
  • 1,316
  • 14
  • 26
  • 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 Mar 01 '16 at 16:51

1 Answers1

4

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
Community
  • 1
  • 1
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129