=?WINDOWS-1252?Q?warning:_implicit_declaration_of_function_=91finite=92?=



Hello,

The file lib/arrows.c uses "finite()" to check whether a given float
is not a NaN (sic). But on Linux, this results in a compiler warning
(both on i386 and amd64, checked on Ubuntu Hardy). I traced that down
to the "-std=c89" option. This option implies -ansi, which ultimately
results in undefining "__USE_MISC" in the system headers. That in turn
disables a macro that actually introduces "finite()" in <math.h>.

Mysteriously, the current code works, which probably means that the
compiler is internally defining "finite()" for itself. I tried using
such an undefined macro in a separate program, and it still managed to
differentiate between a NaN and a finite number.

I am no expert at portable code, and this much investigation has
itself been instructive. What is the best way to remove the warning?

a) A portable way to check whether a float is finite, is made
available by the C99 in the form of the "isfinite" macro. This
eliminates all the platform specific #defines needed in the current
code. What is affected if we enable C99? Dia compiles with gcc when
using C99 mode, but I don't know the state of other platforms.

b) If the plan is to stick to C89, then we must define __USE_MISC
before <math.h> is included, when using gcc. This is equivalent to the
Windows- and OS/2-specific code that defines the "finite" macro in
platform-dependent ways. I suppose the correct place for this is
<config.h>, probably through the auto-tools.

Note that this "problem" is merely academic (for now). The current
code works (with warnings) using the current set of compilers, and I
do believe in not fixing things that aren't broken yet, but still ...

Sameer.
-- 
http://www.it.iitb.ac.in/~sameerds/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]