C++: Platform dependent types - best pattern

Viewed 2262

I'm looking for a pattern to organize header files for multiple platforms in C++.

I have a wrapper .h file that should compile under both Linux and Win32.

Is this the best I can do?

// defs.h

#if defined(WIN32)
#include <win32/defs.h>
#elif defined(LINUX)
#include <linux/defs.h>
#else
#error "Unable to determine OS or current OS is not supported!"
#endif

//  Common stuff below here...

I really don't like preprocessor stuff in C++. Is there a clean (and sane) way to do this better?

6 Answers
Related