是否有一个开关可以用 clang 禁用三字母?
我第一次使用 clang 构建了一些(遗留)代码。代码类似于:
sprintf(buf, "%s <%s ????>", p1, p2);
Clang 给出以下警告(-Werror
错误):
test.c:6:33: error: trigraph converted to '}' character [-Werror,-Wtrigraphs]
sprintf(buf, "%s <%s ????>", p1, p2);
^
显然 ??>
并不打算作为三字母,所以我想禁用完全是三字母组(来源并没有故意在任何地方使用它们)。
我已经尝试过 -no-trigraphs
但这并不是一个真正的选择:
clang: warning: argument unused during compilation: '-no-trigraphs'
我可以使用 -Wno-trigraphs
关闭三字母警告,但我不希望三字母转换为实际上发生了。
注意:启用三字母是使用 -std=c89
的意外副作用。
I've got some (legacy) code that I'm building with clang for the first time. The code is something like:
sprintf(buf, "%s <%s ????>", p1, p2);
Clang gives the following warning (error with -Werror
):
test.c:6:33: error: trigraph converted to '}' character [-Werror,-Wtrigraphs]
sprintf(buf, "%s <%s ????>", p1, p2);
^
Clearly the ??>
is not intended as a trigraph, so I want to disable trigraphs entirely (the source does not intentionally use them anywhere).
I have tried -no-trigraphs
but that's not really an option:
clang: warning: argument unused during compilation: '-no-trigraphs'
I can turn off the trigraphs warning with -Wno-trigraphs
but I don't want the trigraph conversion to actually take place at all.
NOTE: Trigraphs were enabled as an unintended side effect of using -std=c89
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 gnu* 模式 - “Trigraphs 默认在 gnu* 模式下关闭;可以通过 -trigraphs 选项启用它们。” (有关其他差异,请参阅 http://clang.llvm.org/docs/UsersManual.html#c_modes和命令行开关)
Try using gnu* mode - "Trigraphs default to being off in gnu* modes; they can be enabled by the -trigraphs option." (see http://clang.llvm.org/docs/UsersManual.html#c_modes for other differences and command line switch)
我看不到禁用三字母组合的明显方法(而不是三字母组合警告)。修复此代码的最简单方法可能是将其更改为:
I couldn't see an obvious way to disable trigraphs (rather than the trigraphs warning). Probably the easiest way to fix this code is to change it to: