我移植从赢到Solaris中,我有一个问题代码公平一点 - 我得到警告的堆:

Warning: Last line in file is not terminated with a newline.

我喜欢的警告 - 而是因为那些巨量的恐怕我可能会错过更重要的一个

其中编译器(cc)的选项应予指定沉默它?

感谢。

有帮助吗?

解决方案

虽然我认为固定的原始源文件的马丁的解决方案将是可取的,如果你真的想禁用警告,然后的此页面描述,您可以用它来禁用特定的警告标志-erroff 。在你的情况添加

-erroff=E_NEWLINE_NOT_LAST

到CC命令行切换换行符警告关闭,e.g:

# Display the warning and the warning tag name.
/opt/forte/sunstudio11_patch2/SUNWspro/bin/cc -errtags=yes test.c
"test.c", line 1: warning: newline not last character in file (E_NEWLINE_NOT_LAST)

# Disable the warning.
/opt/forte/sunstudio11_patch2/SUNWspro/bin/cc -erroff=E_NEWLINE_NOT_LAST test.c 

其他提示

或者你可以一个空行添加到每个文件的结尾。

一个快速壳脚本

find . -name "*.cpp" -exec echo "" >> {} \;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top