[cairo] cairo compiles on win32 (cygwin)
Bill Spitzak
spitzak at d2.com
Fri Jan 23 11:25:54 PST 2004
On Friday 23 January 2004 08:26 am, Andrew Johnson wrote:
> On Fri, 2004-01-23 at 08:40, Richard Worth wrote:
> > Evan Martin wrote:
> I just tried compiling in mingw, and had issues with this, also an
> additional problem I had was with M_PI apparently not being defined in
> math.h which is very odd indeed but was easily fixed by adding an
>
> #ifndef M_PI
> #define M_PI 3.14159265358979323846
> #endif
In my code I use the following fake "math" header to make Win32 have all the
missing symbols we have encountered so far. The solution is the same as the
GL one I posted earlier, there would be a file such as <cairo/math.h> that
can be included if you want to make portable programs:
--- cut here ---
#include <math.h>
#if defined(_WIN32) && !defined(__CYGWIN__)
// things missing from <math.h> on Windows:
# include <float.h>
# ifndef M_PI
# define M_PI 3.14159265358979323846
# define M_PI_2 1.57079632679489661923
# define M_PI_4 0.78539816339744830962
# define M_1_PI 0.31830988618379067154
# define M_2_PI 0.63661977236758134308
# define M_SQRT2 1.41421356237309504880
# define M_SQRT1_2 0.70710678118654752440
# endif
# define rint(v) floor((v)+.5) // not really correct!
# define copysign _copysign
# define drand48() ((double)rand()/RAND_MAX)
# define srand48(n) srand((n));
#endif
#if 1 // All systems seem to be missing rintf:
# define rintf(v) floorf((v)+.5f)
#endif
#if defined(__APPLE__) || defined(__sun__) // bsd?
# define floorf(a) floor(a)
# define ceilf(a) ceil(a)
# define fmodf(a,b) fmod(a,b)
# undef fabsf
# define fabsf(a) fabs(a)
# define sinf(a) sin(a)
# define cosf(a) cos(a)
# define tanf(a) tan(a)
# define asinf(a) asin(a)
# define acosf(a) acos(a)
# define atanf(a) atan(a)
# define atan2f(a,b) atan2(a,b)
# define expf(a) exp(a)
# define logf(a) log(a)
# define log10f(a) log10(a)
# undef sqrtf
# define sqrtf(a) sqrt(a)
#endif
#ifdef __alpha // powf is broken on alphas, at least in gcc
# define powf(a,b) (float)pow(a,b)
#endif
#ifdef _WIN32
# define expm1f(a) expm1(a)
# define log1pf(a) log1p(a)
#endif
--- cut here ---
--
,~,~,~,~ ~ ~ ~ ~
/\_ _|_========___ Bill Spitzak
~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com
More information about the cairo
mailing list