Tuesday, July 19, 2005

NEGATIVE_ONE

I found the following while doing some work with SDL:


if (sizes == (SDL_Rect **)NEGATIVE_ONE) {


The variable 'sizes' was indeed -1, so the truth statement passed. What got me was that someone actually took the time to define -1 as NEGATIVE_ONE. I mean, if that can go through, why not NEGATIVE_TWO, NEGATIVE_THREE, or POSITIVE_FOUR_HUNDRED_AND_SEVEN? A little further investigation revealed the following set of defines:


#ifdef macintosh /* MPW optimization bug? */
#define NEGATIVE_ONE 0xFFFFFFFF
#else
#define NEGATIVE_ONE -1
#endif


My conclusion, part 1: Perhaps I ought to moan less about the quality of my very modern compiler that understands -1.

My conclusion, part 2: Computers are funny. Not funny ha ha, but funny "hmmm".