Compiling Math.h++ 6.x with MSVC 4.2 results in errors in the file <tt>rwlpbla.cpp</tt>


Compiling Math.h++ 6.x with MSVC 4.2 results in errors in the file rwlpbla.cpp.
        cl -I..  -Os    -GX -D_X86_=1 -DWIN32 -DNOMINMAX -DRW_NO_STL=1 -c -nolog
o rwlpbla.cpp
w/math/ : error C2084: function 'double __cdecl abs(double)' already has a body
w/math/ : error C2084: function 'float __cdecl abs(float)' already has a body
NMAKE : fatal error U1077: 'cl' : return code '0x2'


In MSVC 4.2 Microsoft added new definitions to its math.h system header file.


To get around this you must define the macro:
This will allow Microsoft's definition of abs() and will disable ours. You should change this in your rwmathdefs.h header file. You can do this by including the following definition in the rwmathdefs.h header file.
#if defined(_MSC_VER) && _MSC_VER >= 1020
#  define RW_OVERLOADS_ABS 1
To see the origin of this problem, you must compare the MSVC 4.1 and MSVC 4.2 header files. A comparison of the MSVC 4.1 and MSVC 4.2 headers is now given:

For Microft Visual C++ 4.1 - note the absence of abs(float) and abs(double)


Searching for 'abs('...
C:msvc41msdevincludeMATH.H(163):_CRTIMP int     __cdecl abs(int);
C:msvc41msdevincludeMATH.H(171):_CRTIMP double  __cdecl fabs(double);
C:msvc41msdevincludeMATH.H(173):_CRTIMP long    __cdecl labs(long);
C:msvc41msdevincludeMATH.H(183):        int     __cdecl abs(int);
C:msvc41msdevincludeMATH.H(191):        double  __cdecl fabs(double);
C:msvc41msdevincludeMATH.H(193):        long    __cdecl labs(long);
C:msvc41msdevincludeMATH.H(204):_CRTIMP double  __cdecl _cabs(struct _complex);
C:msvc41msdevincludeMATH.H(276):#define fabsl(x)    ((long double)fabs((double)(x)))
C:msvc41msdevincludeMATH.H(338):_CRTIMP double  __cdecl cabs(struct complex);
C:msvc41msdevincludeSTDLIB.H(397):_CRTIMP int    __cdecl abs(int);
C:msvc41msdevincludeSTDLIB.H(400):        int    __cdecl abs(int);
C:msvc41msdevincludeSTDLIB.H(418):_CRTIMP long __cdecl labs(long);
C:msvc41msdevincludeSTDLIB.H(420):        long __cdecl labs(long);
13 occurrence(s) have been found.
For Miscrosft Visual C++ 4.2 - note the presence of abs(float) and abs(double)
Searching for 'abs('...
C:msvc42msdevincludeMATH.H(163):_CRTIMP int     __cdecl abs(int);
C:msvc42msdevincludeMATH.H(171):_CRTIMP double  __cdecl fabs(double);
C:msvc42msdevincludeMATH.H(173):_CRTIMP long    __cdecl labs(long);
C:msvc42msdevincludeMATH.H(183):        int     __cdecl abs(int);
C:msvc42msdevincludeMATH.H(191):        double  __cdecl fabs(double);
C:msvc42msdevincludeMATH.H(193):        long    __cdecl labs(long);
C:msvc42msdevincludeMATH.H(204):_CRTIMP double  __cdecl _cabs(struct _complex);
C:msvc42msdevincludeMATH.H(277):#define fabsl(x)    ((long double)fabs((double)(x)))
C:msvc42msdevincludeMATH.H(311):	{return (fabs((double)_X)); }
C:msvc42msdevincludeMATH.H(363):	{return ((float)fabs((double)_X)); }
C:msvc42msdevincludeMATH.H(436):_CRTIMP double  __cdecl cabs(struct _complex);
C:msvc42msdevincludeMATH.H(532):inline double abs(double _X)
C:msvc42msdevincludeMATH.H(533):	{return (fabs(_X)); }
C:msvc42msdevincludeMATH.H(538):inline float abs(float _X)
C:msvc42msdevincludeMATH.H(556):inline float fabs(float _X)
C:msvc42msdevincludeMATH.H(586):inline long double abs(long double _X)
C:msvc42msdevincludeMATH.H(604):inline long double fabs(long double _X)
C:msvc42msdevincludeSTDLIB.H(407):_CRTIMP int    __cdecl abs(int);
C:msvc42msdevincludeSTDLIB.H(410):        int    __cdecl abs(int);
C:msvc42msdevincludeSTDLIB.H(433):_CRTIMP long __cdecl labs(long);
C:msvc42msdevincludeSTDLIB.H(435):        long __cdecl labs(long);
21 occurrence(s) have been found.

Article ID: 826
Last updated: 29 Jan, 2008
Revision: 1
Legacy -> .h++ -> Compiling Math.h++ 6.x with MSVC 4.2 results in errors in the file <tt>rwlpbla.cpp</tt>