When there are many preprocessor statements and many #ifdef cascades, it\'s hard to get an overview since normally they are not indented. e.g.
#ifdef __WIN32__
#
First, make sure you actually need all the ifdef
statements. Perhaps there's a way to refactor them to keep the number of nested if checks limited? Assuming you do need them:
It would be a good idea to separate the first portion (the includes) into a separate include file:
In your_header.h
:
#ifdef __WIN32__
#include
#else
#include <..>
#endif
Then in the implementation file, you can then keep things more sane. Liberal blank lines and comments are the approach I've typically taken regarding non-indented #ifdef
checks.
#ifndef __WIN32__
#ifdef SOMEOTHER
stmts
// SOMEOTHER
#endif
maybe stmts
// __WIN32__
#endif
All that said, there's no rule that you can't indent preprocessor checks if it makes the code more readable.