Operating System - HP-UX
1832295 Members
2004 Online
110041 Solutions
New Discussion

Problem compiling a C program

 
SOLVED
Go to solution
Sreeni
New Member

Problem compiling a C program

We have a C program compiled in HP-UX 10. It has been working fine. The exe still works fine on HP11.

Needed to make some minor changes. Now, I cannot compile it. I am getting the following error at every function declaration.
(Bundled) cc: "mg.c", line 241: error 1705: Function prototypes are an ANSI feature.

Does anyone know, how this bundled CC is different from the regular CC.

Please help.

5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor

Re: Problem compiling a C program

You bet. The bundled c compiler is K&R and is really only intended for building kernels.
If you are doing any even moderately serious development you are going to have the purchase the ANSI C compiler or the aCC compiler (which also does C++). The other option is gcc available for one of the HP-UX porting centers or from www.gnu.org.

Regards, Clay
If it ain't broke, I can fix that.
Shannon Petry
Honored Contributor

Re: Problem compiling a C program

Another thing to try is to use the ANSI emulation in the K&R compiler
I.E.
cc -Aa -o ouput.exe myprog.c

It may work if you compiled previously with the K&R compiler and not ANSI.

For allignment and performance it is well worth the HP ANSI/C bundle though, and will remove this error. My only complaint about ANSI/C is that it does not support new style comments....

Regards,
Shannon
Microsoft. When do you want a virus today?
Juan González
Trusted Contributor
Solution

Re: Problem compiling a C program

Hi,
try converting your functions to K&R.
You can follow this example:

ANSI
int myfunction(int a, char b) {

/* your code */
}

K&R

int myfunction(a,b)
int a;
char b;
{

/* your code */

}

Best regards
Juan Gonzalez
Sreeni
New Member

Re: Problem compiling a C program

Juan,

Looks like you are putting me in the right track. Most of my errors went away, when I have changed the way you have suggested, by changing the function definition.

I am still having the compilation errors with the main() function.

My code says :

main(int argc, char *argv[]){
....
}

Could you please tell me what would be the syntax in K&R. I am expecting 3 or 4 parameters to the program.

Thanks for your help.
A. Clay Stephenson
Acclaimed Contributor

Re: Problem compiling a C program

Hi Sreeni,

The K&R syntax for main is

int main(argc,argv)
int argc;
char *argv[];
{
....
....
}

But again, this is not a very good development environment for anything serious.

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