Bug 135589 - isinf declaration problem in knumber.cpp
Summary: isinf declaration problem in knumber.cpp
Status: RESOLVED FIXED
Alias: None
Product: kcalc
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Solaris
: NOR normal
Target Milestone: ---
Assignee: Klaus Niederkrüger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-13 14:01 UTC by Jens Hatlak
Modified: 2007-07-02 23:15 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
isinf patch, verbatim copy from kcalc_core.cpp (514 bytes, patch)
2006-11-10 00:39 UTC, Jens Hatlak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Hatlak 2006-10-13 14:01:12 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    Compiled From Sources
Compiler:          gcc 4.0.3 
OS:                Solaris

This is a regression from the KDE 3.5.4 release version:

knumber.cpp: In constructor 'KNumber::KNumber(double)':
knumber.cpp:72: error: 'isinf' was not declared in this scope
knumber.cpp: In member function 'const QString KNumber::toQString(int, int) const':
knumber.cpp:385: warning: comparison between signed and unsigned integer expressions
gmake[4]: *** [knumber.lo] Error 1
gmake[4]: *** Waiting for unfinished jobs....
gmake[4]: Leaving directory `/software/work/packages/BUILD/kdeutils-3.5.5/kcalc/knumber'

I guess this is the culprit:
http://websvn.kde.org/branches/KDE/3.5/kdeutils/kcalc/knumber/knumber.cpp?rev=587473&r1=586579&r2=587473
Comment 1 Jens Hatlak 2006-10-13 14:02:10 UTC
FYI: I know the Product is wrong, but the wizard does not allow to select kdeutils or kcalc...
Comment 2 Steve Evans 2006-10-16 10:48:54 UTC
On Solaris isinf() is declared in <sunmath.h>, so including that will probably solve the problem.
Comment 3 Steve Evans 2006-10-16 10:52:51 UTC
Having just tried including <sunmath.h>, it doesn't solve the problem :-( I should have checked before posting. The man page says:

NAME
     ieee_sun, fp_class, isinf,  isnormal,  issubnormal,  iszero,
     signbit,     nonstandard_arithmetic,    standard_arithmetic,
     ieee_retrospective - miscellaneous functions for IEEE arith-
     metic

SYNOPSIS
     cc [ flag ... ] file ...  -lsunmath -lm [ library ... ]

     #include <sunmath.h>

     enum fp_class_type fp_class(double x);

     int isinf(double x);

but I don't appear to have a sunmath.h include file, so I get this error:

knumber.cpp:22:21: sunmath.h: No such file or directory
Comment 4 Jens Hatlak 2006-10-16 11:03:07 UTC
I do not have sunmath.h on my machine anyway (Solaris 5.8).

Also, configure already seems to check for isinf():
checking for isinf in -lm... no

So kcalc should honor that (check HAVE_FUNC_ISINF).

Also interesting is that there is a custom isinf function in kcalc_core.cpp. Maybe one could use that implementation. I don't know (did only search for the name).
Comment 5 Jens Hatlak 2006-11-10 00:36:10 UTC
It seems I'll have to do this myself - again...

kcalc/kcalc_core.cpp contains the following code lines:

#ifndef HAVE_FUNC_ISINF
        #ifdef HAVE_IEEEFP_H
                #include <ieeefp.h>
        #else
                #include <math.h>
        #endif

int isinf(double x) { return !finite(x) && x==x; }
#endif

This works for knumber/knumber.cpp as well. Simple copy-paste.

Attaching patch, please check in.
Comment 6 Jens Hatlak 2006-11-10 00:39:01 UTC
Created attachment 18487 [details]
isinf patch, verbatim copy from kcalc_core.cpp
Comment 7 Jens Hatlak 2006-11-10 09:42:19 UTC
Stop, back to start. I get:

ld: fatal: symbol `isinf' is multiply-defined:
        (file .libs/kcalc_core.o type=FUNC; file .libs/libkdeinit_kcalc.lax/libknumber.a/knumber.o type=FUNC);

needs further investigation. :-(
Comment 8 Jens Hatlak 2006-11-10 11:33:01 UTC
I'm not a programmer, so this is just a wild guess: Maybe it would work if these lines would be moved to a header file which would then be included by both kcalc/kcalc_core.cpp and kcalc/knumber/knumber.cpp. Help!
Comment 9 Steve Evans 2007-01-30 12:19:41 UTC
A simple solution is to add static to the start of the function definition. However this could mean a proliferation of identical functions. An alternative would be to make isinf a macro. An even better solution would be to add it to the library kdefakes in kdelibs so that all of KDE could use it.
Comment 10 Bernd Kuhls 2007-03-29 23:21:56 UTC
The problem still exists in KDE-3.5.6
Comment 11 Bernd Kuhls 2007-05-24 13:03:07 UTC
The problem still exists in KDE-3.5.7
Comment 12 Aaron J. Seigo 2007-06-28 19:18:15 UTC
SVN commit 681344 by aseigo:

build on systems that don't have isinf, such as various solaris versions
based on a patch by Jens Hatlak
BUGS:135589


 M  +11 -0     knumber.cpp  


--- trunk/KDE/kdeutils/kcalc/knumber/knumber.cpp #681343:681344
@@ -45,6 +45,17 @@
 bool KNumber::_fraction_input = false;
 bool KNumber::_splitoffinteger_output = false;
 
+#ifndef HAVE_FUNC_ISINF
+
+#ifdef HAVE_IEEEEFP_H
+#include <ieeefp.h>
+#else
+#include <math.h>
+#endif
+
+#define isinf(x) !finite(x) && x == x
+#endif
+
 KNumber::KNumber(qint32 num)
 {
   _num = new _knuminteger(num);
Comment 13 Bernd Kuhls 2007-07-02 23:15:17 UTC
The patch works for KDE-3.5.7 as well, thx, but it has a small type:

wrong:
http://websvn.kde.org/trunk/KDE/kdeutils/kcalc/knumber/knumber.cpp?r1=661111&r2=681344
+#ifdef HAVE_IEEEEFP_H

right:
+#ifdef HAVE_IEEEFP_H