[cfe-dev] Can we make libcxx headers more modular for faster compilation?

Lars Viklund zao at acc.umu.se
Thu Oct 3 08:50:08 PDT 2013


On Thu, Oct 03, 2013 at 08:10:18AM +0200, Jonathan Sauer wrote:
> Hello,
> 
> > support.h includes windows.h on win32 platform.
> > Does libstdc++ also include windows.h. I think this single include may be enough to explain the difference.
> 
> I just looked into libc++, and it seems to include windows.h without first defining
> WIN32_LEAN_AND_MEAN. From <http://support.microsoft.com/kb/166474>:
> 
> | WIN32_LEAN_AND_MEAN: Windows Headers use this symbol to exclude rarely-used header files
> 
> Maybe that's a way to speed things up a bit, at least on Windows.

No. NO. NEVER DO THIS.

Defining that macro forces every single user of the Windows API to
always include the Windows.h header themselves before you do, lest they
will forever lose all ability to use very fundamental types in the
Windows headers.

That macro is for end user use only, and shall only be defined when all
participating users agree on its use.

"rarely-used" doesn't help the bloke that actually wanted to use HDROP
or niche libraries like the ATL or WTL in that TU.

If it's in your private libc++ library TUs, sure. But if it has _any_
chance of leaking out into other code? No. Just don't.

-- 
Lars Viklund | zao at acc.umu.se



More information about the cfe-dev mailing list