Operating System - HP-UX
1827293 Members
2560 Online
109717 Solutions
New Discussion

Re: HP ANSI C Compiler and prototype checking

 
Xiang Zhao
New Member

HP ANSI C Compiler and prototype checking

Hi all,

I have a problem about the HP ANSI C compiler.
The product I installed is
B3901BA HP C/ANSI C Developer's Bundle for HP-UX 11.00(S800)
To avoid typo and other prototype inconsistence errors, I'd like to have the HP Ansi C compiler behaves like hp aCC compiler to enforce strict prototype checking.
I mean I'd like the following simple test program won't be compiled under HP ansi cc.

#include

int main(int argc, char **argv) {
printf("%d\n", sum(1,2));
}

int sum(int a, int b) {
return(a+b);
}

Since the function sum has no prototype. When compiles the same program using aCC, aCC reports the following:
Function 'sum' has not been defined yet; cannot call.


Is there any command line switch or directives for HP ANSI C compiler to do this?


Thanks in advance.

-Xiang ZHAO
5 REPLIES 5
Santosh Nair_1
Honored Contributor

Re: HP ANSI C Compiler and prototype checking

Why not use the aCC compiler to compile your code instead of using the Ansi/C compiler? It should be able to compile straight C code.

-Santosh
Life is what's happening while you're busy making other plans
Jeff Machols
Esteemed Contributor

Re: HP ANSI C Compiler and prototype checking

Try one the two options on the cc command line

1) -Aa

2) -Ae

Hope this works
A. Clay Stephenson
Acclaimed Contributor

Re: HP ANSI C Compiler and prototype checking

Hi,

Easy, add the +M flag to the command line.

Clay
If it ain't broke, I can fix that.
Sanjay_6
Honored Contributor

Re: HP ANSI C Compiler and prototype checking

Hi Xiang,

Have a look at the thread below. It may help.

http://docs.hp.com/hpux/onlinedocs/dev/aCC/a_05_30/otherlangs.htm

Hope this helps.

Thanks
A. Clay Stephenson
Acclaimed Contributor

Re: HP ANSI C Compiler and prototype checking


Hi again,

I might as well give you the full syntax:

cc -Aa (or -Ae) +M +We 714 myfile.c

The +M enables ANSI migration warnings
The +We 714 promotes missing prototype warnings to an error. You can add other warning promotions +We 714,715,720 ...

That should do it though I would probably wrap all that in an include for your makefiles. You will probably have to intentionally make a few errors to get all the warnings promoted.
Most of the warnings are listed in
/opt/ansic/lib/nls/msg/C/cc.msgs.

Clay

If it ain't broke, I can fix that.