Operating System - HP-UX
1753844 Members
7398 Online
108806 Solutions
New Discussion юеВ

not sure ANSI C is installed properly

 
SOLVED
Go to solution
Marc Ahrendt
Super Advisor

not sure ANSI C is installed properly

i am getting the following error when compiling a program

cc: "frog2.c", line 11: error 1705: Function prototypes are an ANSI feature.

where line 11 is

main(int argc, char *argv[])

i noticed in the forums that the fix was to use the ANSI C compiler ...well i have one

swlist | grep -i ansi
B3900AA_APZ B.10.20.05 HP C/ANSI C Developer's Bundle for HP-UX 10.20 (S800)

so just wondering if i am using it?

which cc
/usr/bin/cc
ll /usr/bin/cc
lr-xr-xr-t 1 root sys 17 Nov 1 1999 /usr/bin/cc -> /opt/ansic/bin/cc

FYI: i have not written C code in over a decade
hola
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor

Re: not sure ANSI C is installed properly

I really never trust the "which" command; I always use "type" instead.

I rather suspect that ANSI/C is installed but not yet configured.

Do this:
swlist -l fileset -a state | grep -i "ANSI"

to make sure that "configured" appears beside each component.
If it ain't broke, I can fix that.
Marc Ahrendt
Super Advisor

Re: not sure ANSI C is installed properly

below commands were run

swlist -l fileset -a state | grep -i "ANSI"
# C-ANSI-C
C-ANSI-C.C configured
C-ANSI-C.C-HELP configured
C-ANSI-C.C-MAN configured

which cc
/usr/bin/cc

type cc
cc is a tracked alias for /usr/bin/cc
hola
A. Clay Stephenson
Acclaimed Contributor

Re: not sure ANSI C is installed properly

You look to be properly configured. A good check would be

cc -v frog2.c to display the options and executables. At this point, my best guess is that CCOPTS is set and doing -Ac to put the compiler in "compatible" (meaning very old) mode.
If it ain't broke, I can fix that.
Sridhar Bhaskarla
Honored Contributor
Solution

Re: not sure ANSI C is installed properly

Hi Marc,

How about forcing the compiler to use 'ansi' mode. 'cc -Aa file.c'.

Man cc for more information.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Marc Ahrendt
Super Advisor

Re: not sure ANSI C is installed properly

will assign your points later ...system not letting me do it now, but Sridhar you will get a 10

cc -v -ofrog2 frog2.c
cc: CCOPTS is not set.
...

cc -Aa -ofrog2 frog2.c
Worked!!!

FYI: i got "cc -ofrog2 frog2.c" to work without the "-Aa" option by replacing
void main(int argc, char *argv[])
with the following
main(argc,argv)
int argc;
char **argv;
hola
A. Clay Stephenson
Acclaimed Contributor

Re: not sure ANSI C is installed properly

Your last attempt reverted to K&R syntax so that the compile was okay. I don't feel like finding and loading a version of the ANSI C compiler as old as yours but since CCOPTS was not set, it appears that the default mode of your ANSI/C compiler is -Ac (K & R) rather than -Aa. I've never heard of a default for the ANSI/C compiler that was -Ac but I suppose that it's possible. A more likely explanation is that someone has altered the #defines in a header file so that K&R behavior results. Man 5 stdsyms for clues.
If it ain't broke, I can fix that.