This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[trotts@MIT.EDU: bad line in /usr/include/math.h]



Perhaps using #defines for functions is a bad idea?

------- Start of forwarded message -------
Date: Thu, 20 Jul 2000 22:14:03 -0400
To: cygwin@sourceware.cygnus.com
From: Issac Trotts <trotts@MIT.EDU>
Subject: bad line in /usr/include/math.h

I got a very cryptic error message while compiling a C++ class library
called GiNaC (http://www.ginac.de/) that overloads the function log2 
because of the following sinister line in /usr/include/math.h:

#define log2(x) (log(x) / M_LOG2_E)

I first tried to replace the line with inline versions of log2 for float
and double but
the compiler complained that log2 was being redefined.  So I changed the line
to

#ifdef __cplusplus
// Do not define log2
#else
#define log2(x) (log(x) / M_LOG2_E)
#endif

and now the code compiles.  Btw, I also put the following code:

#ifdef log2
#undef log2
#endif

above the line

unsigned log2(unsigned n); 

in the GiNaC header file that originally had the problem, just in case
I get another infected math.h file later on.

- -Issac

------- End of forwarded message -------

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]