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

Francois Pichet pichet2000 at gmail.com
Sun Aug 8 16:03:12 PDT 2010


It doesn't matter that static_cast is a template or not.

Cl.exe will even parse this: (as long as IID_PPV_ARGS_Helper is not called)

   template<typename T> void** IID_PPV_ARGS_Helper(T** pp)
    {
	sdsa fdfdsf df sd fds++ ++ -- < >fdsfd;;;;;<<<>>>
    }

Any valid C++ token sequence will be accepted during a template
definition (or is that a declaration?). The way cl.exe works is
probably to save the template function as a token sequence list and
defer actual parsing and semantic analysis to instantiation time. In
our case IUnknown will then be declared.


On Sun, Aug 8, 2010 at 6:38 PM, Sean Hunt <rideau3 at gmail.com> wrote:
> On 08/08/2010 04:13 PM, Christopher Jefferson wrote:
>> 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
>
> static_cast isn't a template, it's an operator. Does MSVC accept
> "IUnknown * i;" or "static_cast <foo*>(ptr)" when IUnknown and foo
> haven't been declared?
>
> Sean
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>




More information about the cfe-dev mailing list