error compiling broydn.c & newt.c


Neildh
02-02-2003, 08:59 AM
Hi

I have just downloaded the UNIX version of NR and I am installing on an HP workstation HP-UX 11.10 and using HP's ANSI C compiler.

I get this error during compile phase when creating the libs.

cc: "broydn.c", line 25: error 1584: Inconsistent type declaration: "fmin".
cc: "broydn.c", line 25: error 1711: Inconsistent parameter list declaration for "fmin".
cc: "broydn.c", line 49: error 1621: Too few arguments for fmin.
cc: "broydn.c", line 49: error 1718: Types are not assignment-compatible.
cc: "broydn.c", line 49: warning 563: Argument #1 is not the correct type.
cc: "broydn.c", line 126: warning 604: Pointers are not assignment-compatible.
cc: "broydn.c", line 126: warning 563: Argument #10 is not the correct type.
*** Error exit code 1

This affects both broydn.c and newt.c with the same error from newt.c subs newt.c for broydn.c in the above. The commonalilty is the function fmin. The error is fatal in both cases and the make terminates. All other routines compile without problems. Any one got an ideas about this and what the solution might be. I have a feeling it needs a compiler directive but I can't see from HP's manual what that might be.

Neil



:confused:

Saul Teukolsky
02-02-2003, 12:41 PM
I think the problem may be that math.h on your system may include a function fmin that is conflicting with the fmin defined in nr.h. (Such a definition is not in the ANSI standard, I believe, but is in a POSIX standard.) One possible workaround is to rename fmin in nr.h and in broydn.c and newt.c. Another would be to try a compiler directive to enforce the ANSI standard. I'm not sure what the directive is on your system, but it would be something like
-DANSI

Let us know what works!

Saul Teukolsky

Neildh
02-02-2003, 03:36 PM
Hi Saul

You are quite right, the compiler by default allows both posix and ansi. I used as you sugested a directive to compile strict ansi. This solved the problem and the process completed. The required directive for the HP ansic compiler is -Aa.

Thank you for your help in this

:D

riprock99
08-19-2003, 10:55 PM
I seem to be having a related problem when compiling a program that calls math.h and nr.h on Mac OS X. The error looks like:

In file included from hurst.c:14:
/usr/local/include/nr.h:183: conflicting types for `fmin'
/usr/include/architecture/ppc/math.h:310: previous declaration of `fmin'

The Mac math.h library defines it as a function operating on 2 doubles, unlike the nr.h library. I could rename the fmin function for nr.h, but I imagine it could be buried in quite a few NR routines.

The other option, using a compiler flag -ansi, or -std=c89, etc., fails to correct the issue. OS X cc is a derivative of gcc, so I am surprised it didn't work.

Any ideas?

Many thanks,

S-

Sherlock
11-22-2003, 05:46 PM
Actually, the function name fmin() appears in just five files:

miser
fmin
newt
broydn
nr.h


so it is not difficult to change it to nr_fmin(), or some other name that distinguishes it from the POSIX function.