[cfe-dev] CLang compiling windows.h from the Windows SDK

Douglas Gregor dgregor at apple.com
Sun Aug 8 19:55:08 PDT 2010


We could push the forward declaration into the predefines buffer for Windows targets. 

Sent from my iPhone

On Aug 8, 2010, at 4:57 PM, Francois Pichet <pichet2000 at gmail.com> wrote:

> To get around this problem:
> I create a file inc.h containing just 1 forward declaration:
> struct IUnknown;
> 
> Then I call clang using the force include option "-include inc.h"
> Work fine for me. For my needs, no patch needed in clang.
> 
> 
> On Sun, Aug 8, 2010 at 6:13 PM, Christopher Jefferson
> <chris at bubblescope.net> wrote:
>> 
>> On 8 Aug 2010, at 21:07, Douglas Gregor wrote:
>> 
>>> 
>>>> 3. CLang doesn't like:
>>>>    template<typename T> void** IID_PPV_ARGS_Helper(T** pp)
>>>>    {
>>>>       static_cast<IUnknown*>(*pp);            <=== clang error:
>>>> unknown type name 'IUnknown'
>>>>       return reinterpret_cast<void**>(pp);
>>>>    }
>>>> Note that 'IUnknown' is actually undefined at this point but MSVC accept it.
>>> 
>>> Is it truly undeclared, or is it some kind of magic type? The former is very hard to deal with.
>> 
>> It is truly undeclared, this is due to windows being lax on what it accepts in templates. However, with some careful consideration, clang could possibly consider making it a magic type, if there is only a very small number of such hacks required to parse windows.h. I haven't done a careful analysis of how many such examples there are.
>> 
>> Chris



More information about the cfe-dev mailing list