[cfe-dev] Windows headers that are troublesome for clang

Nico Rieck nico.rieck at gmail.com
Thu Aug 28 13:51:40 PDT 2014


On 27.08.2014 06:10, James Gregurich wrote:
> What I would hope is possible is to be able to specify on a per-translation-unit basis to compile the unit in a completely normal fashion, but get microsoft symbols in the .o files OR compile the unit with with the microsoft-spcific adaptations. That way, some units could depend on Windows.h and Win32 and others could depend on libc++ and behave as I would expect on every other platform. If I can do that then I can contrive a shim layer to adapt insulated Win32 code to work with any standard c++ code that I want. 

The main culprits are -fms-compatibility and -fdelayed-template-parsing
(and to a lesser extent -fms-extensions). If you tuck all uses of
Windows SDK headers away then it's enough to compile just these with the
additional flags. Depending on what headers you need, -fms-extensions
and a forward-declared "struct IUnknown;" are often sufficient (I've
used it for lean windows.h, D3D/D2D, multimedia).

-Nico



More information about the cfe-dev mailing list