[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: warning: implicit declaration of function 'finite'
- From: "Sameer Sahasrabuddhe" <sameerds gmail com>
- To: "discussions about usage and development of dia" <dia-list gnome org>
- Subject: Re: warning: implicit declaration of function 'finite'
- Date: Sat, 20 Dec 2008 13:48:01 +0530
Waiting for comments on this patch! I think it's portable, but it
needs to be tested on platforms other than gcc to make sure those
platforms aren't broken!
Sameer.
On Fri, Dec 5, 2008 at 3:01 PM, Sameer Sahasrabuddhe <sameerds gmail com> wrote:
> Hi,
>
> Attaching a patch that introduces a macro called "isfinite", which is
> used if the actual C99 macro with the same name is not available.
> Originally defined in the GNU coreutils:
>
> http://cvs.savannah.gnu.org/viewvc/coreutils/coreutils/src/seq.c?revision=1.95&view=markup
>
> /* Roll our own isfinite rather than using <math.h>, so that we don't
> have to worry about linking -lm just for isfinite. */
> #ifndef isfinite
> # define isfinite(x) ((x) * 0 == 0)
> #endif
>
> This works because in the world of floating point numbers, anything
> multiplied by zero is not always zero. If x is a NaN then the result
> is a NaN and if it is infinite then the result is infinite. So the
> multiplication cannot be optimised away by the compiler.
>
> This definition is supposed to work on all platforms (unless there is
> a bug in the compiler). The reason we might want to use the system
> definition of isfinite is probably only for performance, which is not
> a very big priority here. Hence removed #include <math.h> and #include
> <float.h> since the only purpose of these files was to introduce
> suitable macros for checking finiteness. Also removed the check for
> OS/2.
>
> This change compiles correctly on GCC ... needs checking on other platforms.
>
> Sameer.
> --
> http://www.it.iitb.ac.in/~sameerds/
>
--
http://www.it.iitb.ac.in/~sameerds/
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]