避免警告:未引用的 find_rule 标签
为了让 flex 和其他版本的 lex 之间有更多的兼容性,我们应该在 flex 命令中添加 -l
选项。 这些不兼容性之一是 yylineno(用于存储行号的全局变量)。虽然有两种方法可以激活此选项:
using %option yylineno
或 -l 选项
我总是收到此类警告:
警告 C4102:“find_rule”:未引用标签
请帮助避免此警告!
In order To get more compatibility between flex and other version of lex , we should add -l
option in flex command.
One of these incompatibilities is yylineno
(global variable to store line number). Although there are two ways to activate this option :
using %option yylineno
or -l option
I have always this kind of warning :
warning C4102: 'find_rule' : unreferenced label
any help please to avoid this warning!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
既然您说触发警告的代码是自动生成的并且无法由您控制,那么消除警告的唯一方法就是仅针对该代码抑制它。你有两个选择。
选项一是更改特定文件的编译器设置(不是最好的维护方式)。
选项 2 是将 .c 文件
#include
到另一个文件中,并将其包装到#pragma warning
中:并且(重要!)要么不将有问题的 .c 文件包含到项目或从构建中排除原始 .c 文件(“从构建中排除”属性),以便它不会被编译和链接两次。
Since you say that the code triggering the warning is auto-generated and can't be controlled by you, the only way to get rid of the warning is to suppress it for that code only. You have two options.
Option one is to alter the compiler settings for the specific file (not the best thing to maintain).
Option 2 is to
#include
the .c file into another file and wrap that into#pragma warning
:and (important!) either not include the problematic .c file into the project or exclude the original .c file from build ("Excluded from build" property) so that it is not compiled and linked twice.
根据 C4102 的描述Cause 是未引用的标签:
要防止出现警告,您可以删除未使用的标签或通过修改源:
或指定
/wd4102
作为编译器开关来禁用警告。正如您所说,这是生成的代码,您不希望更改编译器开关是唯一的选择(我能想到)。
Based on the description from C4102 the cause is an unreferenced label:
To prevent the warning you can remove the unused label or disable the warning by either modifying the source:
or by specifying
/wd4102
as a compiler switch.As you state this is generated code which you do not wish to change the compiler switch is the only option (I can think of).