Question

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.

Was it helpful?

Solution

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 

OTHER TIPS

Or you could add an empty line to the end of each file.

A quick shell script

find . -name "*.cpp" -exec echo "" >> {} \;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top