Sun Studio C++ "is not terminated with a newline" warning - how to suppress?
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 sil开发者_JAVA技巧ence it?
Thanks.
Or you could add an empty line to the end of each file.
A quick shell script
find . -name "*.cpp" -exec echo "" >> {} \;
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
-erroff=E_NEWLINE_NOT_LAST
to the CC command line to switch the newline warning off, 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
精彩评论