C++ – Small question about precompiled headers

cprecompiled-headers

Looking at an open source code base i came across this code:

#include "StableHeaders.h"
#include "polygon.h"
#include "exception.h"
#include "vector.h"
...

Now the StableHeaders.h is a precompiled header which is included by a 'control' cpp to force it's generation. The three includes that appear after the precompiled header are also included in the StableHeaders.h file anyway. My question is, are these files included twice so that the code base will build on compilers that don't support precompiled headers? As im assuming that include guards/header caching will make the multiple includes redundant anyway…

EDIT btw, the stableheaders.h file has a check for win32 (roughly) so again im assuming that the includes inside stableheaders.h wont be included on compilers that don't support precompiled headers.

Best Answer

Compilers that don't support precompiled headers would just include StableHeaders.h and reparse it every time (rather than using the precompiled file). It won't cause any problems neither does it fix any problems for certain compilers as you asked. I think its just a minor 'mistake' that probably happened over time during development.

Related Topic