I was trying to compile some OpenInventor code on Linux
(RedHat 6.2 + SGI ProPack 1.3 on a 330 SGI station). The following
simple code:
#include <Inventor/SoDB.h>
#include <Inventor/SoInput.h>
#include <Inventor/SoPath.h>
fails to compile with g++ (2.91.66 or 2.96.x):
In file included from /usr/include/math.h:82,
from /usr/include/Inventor/SbTime.h:63,
from /usr/include/Inventor/sensors/SoSensorManager.h:65,
from /usr/include/Inventor/SoDB.h:59,
from geInventor.C:1:
/usr/include/bits/mathcalls.h:54: declaration of C function `float acos(float)'
conflicts with
/usr/include/bits/mathcalls.h:54: previous declaration `double acos(double)'
here
/usr/include/bits/mathcalls.h:56: declaration of C function `float asin(float)'
conflicts with
/usr/include/bits/mathcalls.h:56: previous declaration `double asin(double)'
here
/usr/include/bits/mathcalls.h:58: declaration of C function `float atan(float)'
conflicts with
/usr/include/bits/mathcalls.h:58: previous declaration `double atan(double)'
here
/usr/include/bits/mathcalls.h:60: declaration of C function `float atan2(float,
float)' conflicts with
/usr/include/bits/mathcalls.h:60: previous declaration `double atan2(double,
double)' here
/usr/include/bits/mathcalls.h:63: declaration of C function `float cos(float)'
conflicts with
/usr/include/bits/mathcalls.h:63: previous declaration `double cos(double)' here
/usr/include/bits/mathcalls.h:65: declaration of C function `float sin(float)'
conflicts with
/usr/include/bits/mathcalls.h:65: previous declaration `double sin(double)' here
/usr/include/bits/mathcalls.h:67: declaration of C function `float tan(float)'
conflicts with
/usr/include/bits/mathcalls.h:67: previous declaration `double tan(double)' here
/usr/include/bits/mathcalls.h:143: declaration of C function `float pow(float,
float)' conflicts with
/usr/include/bits/mathcalls.h:143: previous declaration `double pow(double,
double)' here
/usr/include/bits/mathcalls.h:146: declaration of C function `float
sqrt(float)' conflicts with
/usr/include/bits/mathcalls.h:146: previous declaration `double sqrt(double)'
here
The problem comes from SbBasic.h:
/////////////////////////////////////////////////////////////////////////////
//
// Map the single-precision math functions to the regular ones on
// machines that don't support them.
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(__sgi)
#define acosf acos
#define asinf asin
#define atanf atan
#define atan2f atan2
#define cosf cos
#define sinf sin
#define tanf tan
#define powf pow
#define sqrtf sqrt
#endif /* !defined(__sgi) */
In fact, Linux does have single-precision math functions, so this is
what is causing problems. In this case, the fix appears to be simple:
#if !defined(__sgi) && !defined(__linux)
seems to do the trick.
JF
Jean-Francois Panisset panisset@xxxxxxxxxxxx
Software Engineer
Discreet Logic
|