Steve
Steve

Reputation: 551

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 silence it?

Thanks.

Upvotes: 0

Views: 1393

Answers (2)

jon hanson
jon hanson

Reputation: 9408

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 

Upvotes: 1

Loki Astari
Loki Astari

Reputation: 264649

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

A quick shell script

find . -name "*.cpp" -exec echo "" >> {} \;

Upvotes: 2

Related Questions