Sunday, May 22, 2016

The Five Stages of #undef rad1

This was sitting in my "drafts" folder from many moons ago. Looking back on it it's entertaining, so I'll post it now.

If you've had to deal with Windows in C++ land, you are probably aware of some of the many "fun" #defines that Microsoft is guilty of, such as near and far. Or, similarly frustrating for anyone programming trigonometric functions, rad1 and rad2. In the case of the latter, they sometimes manifest in the form of:
Error 1 error C2143: syntax error : missing ')' before 'constant' c:\repos\codebase\lib\headerThatUsesTrig.h
In this "article," I cover the five stages of dealing with Microsoft's rampant #defines, starting from your first completely oblique compiler error, like above.