Operating System - HP-UX
1753515 Members
7674 Online
108795 Solutions
New Discussion юеВ

Re: Alter the compilation flags on HP ANSI C (HP 11.0)

 
johnny ta
Occasional Contributor

Alter the compilation flags on HP ANSI C (HP 11.0)

Hello all,
I try to research about HP ANSI C Compiler warning. Our standard turn off all of the compiler warnings...
things like uninitialized variables, array boundary problems, unused variables....
the HP ANSI C compiler will show us all of this stuff rite? But i have to pass it the right flag.
Can someone help me on this?
Thank you
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor

Re: Alter the compilation flags on HP ANSI C (HP 11.0)

By default, +w2 (warnings that code generation might be affected by these issues) is used. +w1 -- generates all warnings; +w3 - no warnings.

You can also suppress specific warnings using the +W warningnumber1,warningnumber2 argument.

Probably the safest is to run +w1 and then use +W n1,n2,n3 to suppress specific warnings that you deem to be "safe".
If it ain't broke, I can fix that.
johnny ta
Occasional Contributor

Re: Alter the compilation flags on HP ANSI C (HP 11.0)

Thanks Clay,
but it doesn't work for me when i tried +W1.
Here what i type:
first tried:
-DHP9000 -Aa +DAportable -g +W1
second tried:
-DHP9000 -Aa +DAportable -g +W1 +Ww1
third tried:
-DHP9000 -Aa +DAportable -g +W1 +Ww1 +y

It gave me same result..no warning..i expect it should raise something like uninitial variable..

Any idea?
Thanks
A. Clay Stephenson
Acclaimed Contributor

Re: Alter the compilation flags on HP ANSI C (HP 11.0)

The option is +w1. +W339,337 when combined with +w1 will warn about everything except warnings 339 and 337.

However, uninitialized variables are not considered a warning and most C compilers do not emit code to do run-time array boundary checks. (That Microsoft Visual C++ thingy can do array-boundary checks.) The typical way to do array boundary checks is through assert()'s. Man assert for details. The tool that you really seem to be looking for is lint. Of course, my attitude is that array boundary excursions like memory leaks are the sole responsibility of the programmer and should never occur.


lint -s -p -Aa myfile.c

Man lint for more details.

This will find a number of questionable constructs like unused variables and/or functions but will not do array boundary checks (which would be meaningless at compile time) nor will it spot uninitialized variables because there is nothing wrong with them. Mind you, I almost always initialize variables (even auto storage class vaiables) but that is part of programmer discipline.
If it ain't broke, I can fix that.
johnny ta
Occasional Contributor

Re: Alter the compilation flags on HP ANSI C (HP 11.0)

Clay,
we used cc, not lint.
I think it have to be something in cc, but we dont' know yet.
Something is not a warning...but i dont know