info-inventor-dev
[Top] [All Lists]

[patch] do not use trunc()

To: info-inventor-dev@xxxxxxxxxxx
Subject: [patch] do not use trunc()
From: "Steve M. Robbins" <steven.robbins@xxxxxxxxxxxx>
Date: Tue, 19 Feb 2002 13:58:17 -0500
Sender: owner-info-inventor-dev@xxxxxxxxxxx
User-agent: Mutt/1.3.27i
Hi,

I maintain OpenInventor for Debian.  On some combination of
hardware and compiler, GCC complained about the function trunc():

 ../../lib/database/src/sb/SbTime.c++:71: new declaration `int trunc(double)'
 /usr/include/bits/mathcalls.h:291: ambiguates old declaration `double 
    trunc(double)'

This is only used in one place in the sources, and is easily 
worked around by the following patch.

-Steve


Index: lib/database/src/sb/SbTime.c++
===================================================================
RCS file: /cvs/inventor/lib/database/src/sb/SbTime.c++,v
retrieving revision 1.4
diff -u -b -B -r1.4 SbTime.c++
--- lib/database/src/sb/SbTime.c++      2001/09/25 00:45:34     1.4
+++ lib/database/src/sb/SbTime.c++      2002/01/27 15:40:31
@@ -67,16 +67,12 @@
 //
 // Use: public
 
-#ifndef __sgi
-inline static int trunc(double x) { return int(x); }
-#endif // !__sgi
-
 SbTime::SbTime(double sec)
 //
 ////////////////////////////////////////////////////////////////////////
 {
     if (sec >= 0) {
-       t.tv_sec = trunc(sec);
+       t.tv_sec = int(sec);
        t.tv_usec = (time_t) (0.5 + (sec - t.tv_sec) * 1000000.0);
     }
     else


-- 
by Rocket to the Moon,
by Airplane to the Rocket,
by Taxi to the Airport,
by Frontdoor to the Taxi,
by throwing back the blanket and laying down the legs ...
- They Might Be Giants


<Prev in Thread] Current Thread [Next in Thread>
  • [patch] do not use trunc(), Steve M. Robbins <=