Conditional compilation fails

One trick is to put the code that confuses it into an include file; the preprocessor won't touch anything in an included file.

The preprocessor will to. The IDE won't. Different applications; different processes.

The best trick is to simply avoid the preprocessor altogether.

I think that you are confusing the C preprocessor and the IDE.