Comment by green7ea

4 days ago

I remember using it all the time for the Windows headers because they pollutes the compilation unit like you wouldn't believe — the rule was to only include them in c/cpp files.

We put

    #define WIN32_LEAN_AND_MEAN 1
    #include <windows.h>

In precompiled headers to solve that particular problem.

  • That's kind of a hack, still best only used in implementation files, not headers.

    • The irony is that including/using many standard c++ headers is far far more expensive than including a lean windows.h these days.

      To make hobby-coding fun, i use a mstdp.hpp that implements "naive" versions of unique,shared,function,etc that compiles faster than including just one of the std versions (and yes, MSVC versions of those libraries seem to be excessivly complex).

      4 replies →

    • That may be true, but it's a "hack" that has caused me approximately 1 issue in 15 years of writing C++ professionally, and that issue was a problem with our build system not the precompiled header.

      > Still best only used in implementation files, not headers.

      We only compile implementation files!