simonb.com: blog > articles from Saturday, 26 March 2005

skip to content
You are here: 

On Saturday, 26 March 2005 we wrote…

Saturday, 26 March 2005

Careful Where You Put Your Hash

In which we discover the delights of # placement.

If you’ve written code for more than one platform you’ve probably come across something that looks like this:

#if defined(_WIN32)
#elif defined(LINUX)
#endif

A lot of us indent to make things more readable so you might end up with this:

#if defined(_WIN32)
#include <io.h>
#elif defined(LINUX)
#include <ioctl.h>
#endif

According to K&R that’s valid. But some tools don’t do what you think. Take makedepend for example. I just discovered that if the line does not start with # then makedepend ignores it. So that file you…

read more

Tags: