How do I show all compiler warnings with Sun Studio?

  • Follow


gcc has the option -Wall to show all warnings. I don't see anything like 
that with Sun's compiler

  $ /opt/SUNWspro/bin/cc -flags | grep -i warning
-erroff=<t>     Suppress warnings specified by tags t(%none, %all, <tag 
list>)
-errwarn=<t>    Treats warnings specified by tags t(%none, %all, <tag 
list>) as errors
-w              Suppress compiler warning messages
-xtransition    Emit warnings for differences between K&R C and ANSI C
-xvpara         Verbose parallelization warnings


Should I

1) Not bother with any flags (i.e. the default is to show all warnings),
2) Add -erroff=none
3) Add -xtransition in addition to above

or any other combination which will emit warnings for any poor code.

Dave


-- 
I respectfully request that this message is not archived by companies as
unscrupulous as 'Experts Exchange' . In case you are unaware,
'Experts Exchange'  take questions posted on the web and try to find
idiots stupid enough to pay for the answers, which were posted freely
by others. They are leeches.
0
Reply foo25 (218) 8/2/2009 12:56:32 PM

On 2009-08-02 13:56:32 +0100, Dave <foo@coo.com> said:

> gcc has the option -Wall to show all warnings. I don't see anything 
> like that with Sun's compiler
> 
>   $ /opt/SUNWspro/bin/cc -flags | grep -i warning
> -erroff=<t>     Suppress warnings specified by tags t(%none, %all, <tag list>)
> -errwarn=<t>    Treats warnings specified by tags t(%none, %all, <tag 
> list>) as errors
> -w              Suppress compiler warning messages
> -xtransition    Emit warnings for differences between K&R C and ANSI C
> -xvpara         Verbose parallelization warnings
> 
> 
> Should I
> 
> 1) Not bother with any flags (i.e. the default is to show all warnings),
> 2) Add -erroff=none
> 3) Add -xtransition in addition to above
> 
> or any other combination which will emit warnings for any poor code.

-v is good for cc (stricter semantic checking), though not for CC.

-- 
Chris

0
Reply Chris 8/2/2009 1:47:40 PM


On 2 Aug, 14:47, Chris Ridd <chrisr...@mac.com> wrote:
> On 2009-08-02 13:56:32 +0100, Dave <f...@coo.com> said:
>
>
>
> > gcc has the option -Wall to show all warnings. I don't see anything
> > like that with Sun's compiler
>
> > =A0 $ /opt/SUNWspro/bin/cc -flags | grep -i warning
> > -erroff=3D<t> =A0 =A0 Suppress warnings specified by tags t(%none, %all=
, <tag list>)
> > -errwarn=3D<t> =A0 =A0Treats warnings specified by tags t(%none, %all, =
<tag
> > list>) as errors
> > -w =A0 =A0 =A0 =A0 =A0 =A0 =A0Suppress compiler warning messages
> > -xtransition =A0 =A0Emit warnings for differences between K&R C and ANS=
I C
> > -xvpara =A0 =A0 =A0 =A0 Verbose parallelization warnings
>
> > Should I
>
> > 1) Not bother with any flags (i.e. the default is to show all warnings)=
,
> > 2) Add -erroff=3Dnone
> > 3) Add -xtransition in addition to above
>
> > or any other combination which will emit warnings for any poor code.
>
> -v is good for cc (stricter semantic checking), though not for CC.
>
> --
> Chris

use

 lint -errchk=3D%all -fd -Ncheck -Nlevel=3D4 -p
0
Reply david 8/2/2009 3:43:09 PM

Dave wrote:
> gcc has the option -Wall to show all warnings. I don't see anything like 
> that with Sun's compiler
> 
>  $ /opt/SUNWspro/bin/cc -flags | grep -i warning
> -erroff=<t>     Suppress warnings specified by tags t(%none, %all, <tag 
> list>)
> -errwarn=<t>    Treats warnings specified by tags t(%none, %all, <tag 
> list>) as errors
> -w              Suppress compiler warning messages
> -xtransition    Emit warnings for differences between K&R C and ANSI C
> -xvpara         Verbose parallelization warnings
> 
> 
> Should I
> 
> 1) Not bother with any flags (i.e. the default is to show all warnings),
> 2) Add -erroff=none
> 3) Add -xtransition in addition to above
> 
> or any other combination which will emit warnings for any poor code.

4) Use lint.

Sun splits the compiling and some checking between cc and lint.  gcc 
tries to be a one stop shop.

-- 
Ian Collins
0
Reply Ian 8/2/2009 7:09:43 PM

On 2009-08-02 20:09:43 +0100, Ian Collins <ian-news@hotmail.com> said:

> 4) Use lint.
> 
> Sun splits the compiling and some checking between cc and lint.  gcc 
> tries to be a one stop shop.

I read somewhere that Sun Studio $future will have the compilers do 
more of the checking. I can't find the reference though :-(
-- 
Chris

0
Reply Chris 8/2/2009 7:36:30 PM

Chris Ridd wrote:
> On 2009-08-02 20:09:43 +0100, Ian Collins <ian-news@hotmail.com> said:
> 
>> 4) Use lint.
>>
>> Sun splits the compiling and some checking between cc and lint.  gcc 
>> tries to be a one stop shop.
> 
> I read somewhere that Sun Studio $future will have the compilers do more 
> of the checking. I can't find the reference though :-(

Traditionally, compilers have diagnosed syntactical errors in the source 
code.  Unix broke this tradition by separating the compilation and 
diagnostic functions in C.

It works either way.  Having learned on systems where the compiler 
diagnosed errors (IBM/360, VAX/VMS) I tend to prefer it.

Since the compiler has to parse each line of the source code anyway, it 
makes sense to issue diagnostic messages.  ISTR that at least one of the 
Fortran compilers I used would flag variables that were never assigned a 
value; another handy feature.


0
Reply Richard 8/2/2009 7:58:45 PM

Richard B. Gilbert wrote:
> Chris Ridd wrote:
>> On 2009-08-02 20:09:43 +0100, Ian Collins <ian-news@hotmail.com> said:
>>
>>> 4) Use lint.
>>>
>>> Sun splits the compiling and some checking between cc and lint.  gcc 
>>> tries to be a one stop shop.
>>
>> I read somewhere that Sun Studio $future will have the compilers do 
>> more of the checking. I can't find the reference though :-(
> 
> Traditionally, compilers have diagnosed syntactical errors in the source 
> code.  Unix broke this tradition by separating the compilation and 
> diagnostic functions in C.

cc does diagnose syntactical errors in the source code.

> It works either way.  Having learned on systems where the compiler 
> diagnosed errors (IBM/360, VAX/VMS) I tend to prefer it.
> 
> Since the compiler has to parse each line of the source code anyway, it 
> makes sense to issue diagnostic messages.  ISTR that at least one of the 
> Fortran compilers I used would flag variables that were never assigned a 
> value; another handy feature.

lint can go a step further and examine groups of files, or all the files 
in an application to look for possible errors not detectable ins single 
compilation unit.

-- 
Ian Collins
0
Reply Ian 8/3/2009 5:16:20 AM

Ian Collins wrote:
> Dave wrote:
>> gcc has the option -Wall to show all warnings. I don't see anything 
>> like that with Sun's compiler
>>
>>  $ /opt/SUNWspro/bin/cc -flags | grep -i warning
>> -erroff=<t>     Suppress warnings specified by tags t(%none, %all, 
>> <tag list>)
>> -errwarn=<t>    Treats warnings specified by tags t(%none, %all, <tag 
>> list>) as errors
>> -w              Suppress compiler warning messages
>> -xtransition    Emit warnings for differences between K&R C and ANSI C
>> -xvpara         Verbose parallelization warnings
>>
>>
>> Should I
>>
>> 1) Not bother with any flags (i.e. the default is to show all warnings),
>> 2) Add -erroff=none
>> 3) Add -xtransition in addition to above
>>
>> or any other combination which will emit warnings for any poor code.
> 
> 4) Use lint.
> 
> Sun splits the compiling and some checking between cc and lint.  gcc 
> tries to be a one stop shop.
> 


I do not want to do that.

I want to add some flags to a script which compiles programs so the 
error checking is somewhat better than it used to be. I've found bits of 
code where people purposely send warnings to /dev/null, and on another 
they use a flag to gcc to suppress warning messages from the assembler.

That failed to work on Solaris, as the Sun assembler does not take the 
same option as the GNU one to suppress warnings.

What's the best options I can add to cc and CC to show warnings, in much 
the same was as -Wall does on gcc?

-- 
I respectfully request that this message is not archived by companies as
unscrupulous as 'Experts Exchange' . In case you are unaware,
'Experts Exchange'  take questions posted on the web and try to find
idiots stupid enough to pay for the answers, which were posted freely
by others. They are leeches.
0
Reply Dave 8/3/2009 7:51:00 AM

Ian Collins wrote:

> 
> lint can go a step further and examine groups of files, or all the files 
> in an application to look for possible errors not detectable ins single 
> compilation unit.
> 

This is well outside what I am looking for. There are millions of lines 
of code written by others. It's not practical for me to go to this level 
of detail. I'm basically writing a wrapper script which will be used for 
compiling the code. I'm just adding some sensible options to the 
compiler, so we are aware of the warnings and can note those to the 
developers of other programs. I'm not looking to do a very detailed 
analysis. Neither can I afford the time. The program takes over a day to 
build on a SPARC, so spending even more time with lint will only slow 
the process further. (That might be true with compiler options too, 
which I must admit I had not even considered.)



-- 
I respectfully request that this message is not archived by companies as
unscrupulous as 'Experts Exchange' . In case you are unaware,
'Experts Exchange'  take questions posted on the web and try to find
idiots stupid enough to pay for the answers, which were posted freely
by others. They are leeches.
0
Reply Dave 8/3/2009 7:59:00 AM

Dave wrote:
> Ian Collins wrote:
>>
>> 4) Use lint.
>>
>> Sun splits the compiling and some checking between cc and lint.  gcc 
>> tries to be a one stop shop.
>>
> 
> 
> I do not want to do that.
> 
> I want to add some flags to a script which compiles programs so the 
> error checking is somewhat better than it used to be. I've found bits of 
> code where people purposely send warnings to /dev/null, and on another 
> they use a flag to gcc to suppress warning messages from the assembler.
> 
> That failed to work on Solaris, as the Sun assembler does not take the 
> same option as the GNU one to suppress warnings.
> 
> What's the best options I can add to cc and CC to show warnings, in much 
> the same was as -Wall does on gcc?

There isn't an equivalent.  Just use the default, which is much stricter 
(in terms of language compliance) than gcc default.  Without options, 
gcc compiles the language known as "gcc"!

-- 
Ian Collins
0
Reply Ian 8/3/2009 9:10:39 AM

Dave wrote:
> Ian Collins wrote:
> 
>>
>> lint can go a step further and examine groups of files, or all the 
>> files in an application to look for possible errors not detectable ins 
>> single compilation unit.
>>
> 
> This is well outside what I am looking for. There are millions of lines 
> of code written by others. It's not practical for me to go to this level 
> of detail. I'm basically writing a wrapper script which will be used for 
> compiling the code. I'm just adding some sensible options to the 
> compiler, so we are aware of the warnings and can note those to the 
> developers of other programs. I'm not looking to do a very detailed 
> analysis. Neither can I afford the time. The program takes over a day to 
> build on a SPARC, so spending even more time with lint will only slow 
> the process further. (That might be true with compiler options too, 
> which I must admit I had not even considered.)
> 
> 
> 

IF you can be certain that the code you are trying to compile is both 
syntactically and logically correct you could do that!  Expecting real 
code to exhibit these features is equivalent to believing in Santa Claus 
and the Easter Bunny.
0
Reply Richard 8/3/2009 11:31:32 AM

Dave  wrote:

> What's the best options I can add to cc and CC to show warnings, in much 
> the same was as -Wall does on gcc?

With CC (not cc), you can use +w (or even +w2, but that will be too
much). The default may already provide enough (sometimes too many)
warnings though.

Someone already mentioned cc -v.
0
Reply Marc 8/3/2009 9:35:01 PM

Marc wrote:
> Dave  wrote:
> 
>> What's the best options I can add to cc and CC to show warnings, in much 
>> the same was as -Wall does on gcc?
> 
> With CC (not cc), you can use +w (or even +w2, but that will be too
> much). The default may already provide enough (sometimes too many)
> warnings though.
> 
> Someone already mentioned cc -v.

Thank you. Have you any idea how long those options have been on Sun 
compilers? I'd like to use something that will work with older versions 
of the compilers if that is possible. At the end of the day, we can 
always say 'you need Sun Studio xyz' or similar.


-- 
I respectfully request that this message is not archived by companies as
unscrupulous as 'Experts Exchange' . In case you are unaware,
'Experts Exchange'  take questions posted on the web and try to find
idiots stupid enough to pay for the answers, which were posted freely
by others. They are leeches.
0
Reply Dave 8/5/2009 10:21:49 PM

Dave wrote:
> Marc wrote:
>> Dave  wrote:
>>
>>> What's the best options I can add to cc and CC to show warnings, in 
>>> much the same was as -Wall does on gcc?
>>
>> With CC (not cc), you can use +w (or even +w2, but that will be too
>> much). The default may already provide enough (sometimes too many)
>> warnings though.
>>
>> Someone already mentioned cc -v.
> 
> Thank you. Have you any idea how long those options have been on Sun 
> compilers? I'd like to use something that will work with older versions 
> of the compilers if that is possible. At the end of the day, we can 
> always say 'you need Sun Studio xyz' or similar.

There's no got reason to specify older (possibly unsupported) versions 
of a free tool!

-- 
Ian Collins
0
Reply Ian 8/6/2009 6:00:56 AM

Ian Collins wrote:
> Dave wrote:
>> Marc wrote:
>>> Dave  wrote:
>>>
>>>> What's the best options I can add to cc and CC to show warnings, in 
>>>> much the same was as -Wall does on gcc?
>>>
>>> With CC (not cc), you can use +w (or even +w2, but that will be too
>>> much). The default may already provide enough (sometimes too many)
>>> warnings though.
>>>
>>> Someone already mentioned cc -v.
>>
>> Thank you. Have you any idea how long those options have been on Sun 
>> compilers? I'd like to use something that will work with older 
>> versions of the compilers if that is possible. At the end of the day, 
>> we can always say 'you need Sun Studio xyz' or similar.
> 
> There's no got reason to specify older (possibly unsupported) versions 
> of a free tool!
> 

There is if a user wants to build a program and does not have root 
access. To the best of my knowledge, you need to be root to install Sun 
Studio.


In any case, I'd rather write code that does not demand that someone has 
the latest tools present. The fact is, a lot of people do not run the 
latest release of Solaris, use the latest Sun Studio, the latest gcc, 
the latest perl .... - yet they are all free.

In my personal opinion, it would be good to produce code that would work 
with software that is 5 years old. That seems a reasonable number to me. 
Don't expect people to have the latest versions of everything, but don't 
wast time supporting antique systems either.
-- 
I respectfully request that this message is not archived by companies as
unscrupulous as 'Experts Exchange' . In case you are unaware,
'Experts Exchange'  take questions posted on the web and try to find
idiots stupid enough to pay for the answers, which were posted freely
by others. They are leeches.
0
Reply Dave 8/7/2009 12:52:03 AM

Dave  wrote:

>>> Thank you. Have you any idea how long those options have been on Sun 
>>> compilers? I'd like to use something that will work with older 
>>> versions of the compilers if that is possible. At the end of the day, 
>>> we can always say 'you need Sun Studio xyz' or similar.
>> 
>> There's no got reason to specify older (possibly unsupported) versions 
>> of a free tool!
> 
> There is if a user wants to build a program and does not have root 
> access. To the best of my knowledge, you need to be root to install Sun 
> Studio.

Actually, you don't. There is a tarball download specifically for this.
Even before that it was possible, although not straightforward. Now only
the patching is a bit complicated (unless there was some recent progress,
I haven't checked).
0
Reply Marc 8/7/2009 3:30:05 AM

Marc wrote:
> Dave  wrote:
> 
>>>> Thank you. Have you any idea how long those options have been on Sun 
>>>> compilers? I'd like to use something that will work with older 
>>>> versions of the compilers if that is possible. At the end of the day, 
>>>> we can always say 'you need Sun Studio xyz' or similar.
>>> There's no got reason to specify older (possibly unsupported) versions 
>>> of a free tool!
>> There is if a user wants to build a program and does not have root 
>> access. To the best of my knowledge, you need to be root to install Sun 
>> Studio.
> 
> Actually, you don't. There is a tarball download specifically for this.
> Even before that it was possible, although not straightforward. Now only
> the patching is a bit complicated (unless there was some recent progress,
> I haven't checked).

They update the tarball.

-- 
Ian Collins
0
Reply Ian 8/7/2009 5:35:25 AM

Marc wrote:
> Dave  wrote:
> 
>>>> Thank you. Have you any idea how long those options have been on Sun 
>>>> compilers? I'd like to use something that will work with older 
>>>> versions of the compilers if that is possible. At the end of the day, 
>>>> we can always say 'you need Sun Studio xyz' or similar.
>>> There's no got reason to specify older (possibly unsupported) versions 
>>> of a free tool!
>> There is if a user wants to build a program and does not have root 
>> access. To the best of my knowledge, you need to be root to install Sun 
>> Studio.
> 
> Actually, you don't. There is a tarball download specifically for this.
> Even before that it was possible, although not straightforward. Now only
> the patching is a bit complicated (unless there was some recent progress,
> I haven't checked).

Thank you. I was not aware of that.

But it still does not get around the fact that not everyone has the 
latest versions of tools installed - despite the fact they are free. So 
to have a requirement that someone download the latest Sun Studio is not 
IMHO a very good one.

-- 
I respectfully request that this message is not archived by companies as
unscrupulous as 'Experts Exchange' . In case you are unaware,
'Experts Exchange'  take questions posted on the web and try to find
idiots stupid enough to pay for the answers, which were posted freely
by others. They are leeches.
0
Reply Dave 8/7/2009 8:56:03 PM

17 Replies
578 Views

(page loaded in 0.386 seconds)

Similiar Articles:


















7/22/2012 9:29:07 PM


Reply: