I am working on a legacy project that uses yacc - 1.9 20130304. The generated .c files contain the sccsid string (from the skeleton.c):
#ifndef lint
static const char <file_name>sccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
When compiling with gcc -Wall I get the expected warning:
warning: '<file_name>sccsid' defined but not used [-Wunused-const-variable=]
One way that I can remove the warning is to somehow add __attribute__((unused))
in the generated file but that would be very tedious since the project is huge and contains a lot of parser-generators with a complicated makefile structure.
Therefore I am wondering if there is a simpler way. Can I tell yacc to not generate the sccs id? Or can I instruct gcc to not warn on #ifdef lint? Or maybe some other solution?
Edit: I cannot upgrade to a newer version of byacc (that doesn't insert the sccsid) or modify skeleton.c and recompile yacc because we must ship the software with a specific version of linux and libraries due to software assurance guarantees.
Any suggestions/hints are appreciated!
Converting comments into an answer.
There are multiple possibilities:
-Wno-unused-const-variable
to your command-line options, but it might suppress other warnings about other variables that you should pay attention to.-Dlint
? It will eliminate the variable from the compiler's view.The last (compiling the grammars with
-Dlint
) is probably the best. Code that is protected by#ifndef lint
is rarely crucial to the operation of the code. It was used to hide dubious constructs from thelint
program back in the days whenlint
was used. These days, with proper care in the use of headers and detailed warnings from compilers,lint
is rarely used.