Sun Studio C++ “不以换行符终止”警告——如何抑制?
我已经将相当多的代码从 Win 移植到 Solaris,这是我遇到的问题之一 - 我收到了一堆警告:
Warning: Last line in file is not terminated with a newline.
我喜欢警告 - 但由于警告的数量太多,我担心我可能会错过更重要的警告。
我应该指定哪个编译器 (cc) 选项来使其静音?
谢谢。
I have ported a fair bit of code from Win to Solaris, one of the issues I have -
I am getting a heaps of warnings:
Warning: Last line in file is not terminated with a newline.
I like warnings - but because of the sheer amount of those I am afraid I could miss more important one.
Which compiler (cc) option should I specify to silence it?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
或者您可以在每个文件的末尾添加一个空行。
一个快速的 shell 脚本
Or you could add an empty line to the end of each file.
A quick shell script
虽然我认为马丁修复原始源文件的解决方案会更好,但如果您确实想禁用警告,那么 此页 介绍 -erroff 标志,您可以使用该标志来禁用特定警告。在您的情况下,添加
到 CC 命令行以关闭换行符警告,例如:
Although i think Martin's solution of fixing the original source files would be preferable, if you really want to disable the warnings then this page describes the -erroff flag which you can use to disable specific warnings. In your case add
to the CC command line to switch the newline warning off, e.g.: