[cfe-dev] CLang compiling windows.h from the Windows SDK
Dimitry Andric
dimitry at andric.com
Sun Aug 8 15:41:18 PDT 2010
On 2010-08-09 00:13, Christopher Jefferson 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.
Ehm, I have a file "Unknwn.h" in my Microsoft SDK dir, that defines
IUnknown as:
MIDL_INTERFACE("00000000-0000-0000-C000-000000000046")
IUnknown
{
public:
[...]
where MIDL_INTERFACE basically means "struct" (from MqOaI.h):
#ifndef MIDL_INTERFACE
#if _MSC_VER >= 1100
#define MIDL_INTERFACE(x) struct __declspec(uuid(x)) __declspec(novtable)
#else
#define MIDL_INTERFACE(x) struct
#endif //_MSC_VER
#endif //MIDL_INTERFACE
The only declaration in Unknwn.h that I can't parse is this IUnknown
forward declaration, again in Unknwn.h:
#ifndef __IUnknown_FWD_DEFINED__
#define __IUnknown_FWD_DEFINED__
typedef interface IUnknown IUnknown;
#endif /* __IUnknown_FWD_DEFINED__ */
That "interface" keyword is probably something Microsoft-specific...
More information about the cfe-dev
mailing list