0

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.

4

2 に答える 2

2

または、各ファイルの末尾に空の行を追加することもできます。

簡単なシェルスクリプト

find . -name "*.cpp" -exec echo "" >> {} \;
于 2009-12-17T05:02:02.633 に答える
1

元のソース ファイルを修正する Martin のソリューションが望ましいと思いますが、本当に警告を無効にしたい場合は、このページで特定の警告を無効にするために使用できる -erroff フラグについて説明します。あなたの場合、追加します

-erroff=E_NEWLINE_NOT_LAST

改行警告をオフに切り替えるには、CC コマンド ラインに次のように入力します。

# 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 
于 2009-12-17T11:56:40.617 に答える