Operating System - HP-UX
1846556 Members
2039 Online
110256 Solutions
New Discussion

Re: Error compiling C program on HP-UX

 
SOLVED
Go to solution
Randy Carey
New Member

Error compiling C program on HP-UX

I am trying to compile (i.e., #cc makebar.c) a program on an HP-UX 11.0 server, using "cc". I am getting the following error,

{cc: "makebar.c", line 427: error 1584: Inconsistent type declaration: "round" }

code at and around line 427

427: int round( d )
428: double d;
429:
430:{
431: double z;
432: int i;
433:
434: i = z = floor( d );
435: if ( d - z >= .5 )
436: ++i;
437: return i;
438: }

Is there something wrong with the above code? I noticed while searching on the error message several years back it stated to installed a cumlative patch for the C compiler. Might this imply here?

Thank you in advance for any help.
3 REPLIES 3
H.Merijn Brand (procura
Honored Contributor

Re: Error compiling C program on HP-UX

round () most likely already exixsts as a libc or libm function. You can overrule it like this but I would strongly advise against it and choose a different name. Why not use myround ()?.

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Error compiling C program on HP-UX

Actually, the code as posted (at least as well as my eyeball compiler works) will compile; the problem occurs when you incude those pesky header files that you didn't post. There is a standard lm function round that is a double rather than int and that is what is causing your problem. You must be using because otherwise floor would be returning an int rather than double value.

In any event this is not very pretty (or safe) code. You might consider using the rint() function.
If it ain't broke, I can fix that.
Umapathy S
Honored Contributor

Re: Error compiling C program on HP-UX

Inconsistent type declaration error occurs when the prototype you have declared in some file (header or c file) doesnt match with the function defintion (signature).

Double check that.

HTH
Umapathy
Arise Awake and Stop NOT till the goal is Reached!