trackball.c Compiler Trouble

You may have trouble compiling trackball.c, depending on the compiler that you’re using. The problem is that compilers disagree over the contents of <math.h>.

Unfortunately, there are multiple standards for C libraries. The ANSI/ISO C standard <math.h> specifies only a few math functions. The POSIX standard <math.h> specifies a superset, including several useful constants like M_PI, and several additional functions, including y0() and y1() for computing Bessel functions.

Unfortunately, compilers tend to pick and choose. The “standard” library for the compiler I used includes M_PI but not y0() and y1(). If you’re using Visual C++, you’ll find that its “standard” library does the opposite: it defines y0() and y1() but not M_PI.

The best defense against all of this is probably to define your own constant for PI and to rename y0 and y1. By the time you read this, I’ll have updated trackball.c to do this.

Computers suck. Have I mentioned that?

Comments are closed.