YACC生成的C文件SCCSID警告抑制

发布于 2025-01-25 13:48:53 字数 614 浏览 3 评论 0原文

我正在研究一个使用YACC -1.9 20130304的旧项目。 生成的.c文件包含SCCSID字符串(来自Skeleton.c):

#ifndef lint
static const char <file_name>sccsid[] = "@(#)yaccpar        1.9 (Berkeley) 02/21/93";
#endif

使用GCC-WAL来编译时,我会收到预期的警告:

警告:'&lt; file_name&gt; sccsid'已定义但未使用[-wunused-const-variable = wunuse-cont-varable = = ]

我可以删除警告的一种方法是以某种方式添加__属性__(((未使用))) >一个复杂的制作结构。

因此,我想知道是否有更简单的方法。我可以告诉YACC不要生成SCCS ID吗?还是可以指示海湾合作委员会不要警告#IFDEF棉绒?还是其他解决方案?

编辑:我无法升级到BYACC的较新版本(不插入SCCSID)或修改Skeleton.c和重新编译YACC,因为由于软件保证保证,我们必须使用特定版本的Linux和Linux和库。

任何建议/提示都将不胜感激!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尝蛊 2025-02-01 13:48:53

将注释转换为答案。

有多种可能性:

  • 您可以编辑Skeleton.c文件?这是一个令人讨厌的修复程序,因为每次重新安装YACC时,都必须在所有机器上重做它。
  • 看起来像BYACC -Berkeley Yacc。您拥有更改代码的全部权利 - 这使生活变得更加简单(并且代码不会经常更改)。
  • 另外,将-wno-unused-const-variable添加到您的命令行选项中,但它可能会抑制有关您应该注意的其他变量的其他警告。
  • 您可以用-dlint负担得起(语法文件)吗?它将从编译器的视图中消除变量。

最后的(用-dlint编译语法)可能是最好的。受#ifndef lint保护的代码对于代码的操作很少至关重要。它用于在lint的日子里从lint编程中隐藏可疑构造。如今,在使用标题和编译器的详细警告时,lint很少使用。

Converting comments into an answer.

There are multiple possibilities:

  • You could edit the skeleton.c file? It's a nuisancy fix as you have to redo it on all machines every time Yacc is reinstalled.
  • It looks like Byacc — Berkeley Yacc. You have full rights to change the code — that makes life simpler (and the code won't change often).
  • Alternatively, add -Wno-unused-const-variable to your command-line options, but it might suppress other warnings about other variables that you should pay attention to.
  • Can you afford to compile (the grammar files) with -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 the lint program back in the days when lint was used. These days, with proper care in the use of headers and detailed warnings from compilers, lint is rarely used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文