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

Jesse Towner townerj at gmail.com
Sun Aug 8 15:44:48 PDT 2010


Oh yeah, I agree, I was just recommending that as a start to get the
basics all compiling.

- Jesse

On Sun, 2010-08-08 at 15:52 -0400, Douglas Gregor wrote:
> 
> Sent from my iPhone
> 
> On Aug 8, 2010, at 10:26 AM, Jesse Towner <townerj at gmail.com> wrote:
> 
> > I think Per was also defining WIN32_LEAN_AND_MEAN in addition to setting
> > up _MSC_VER before including Windows.h to reduce what was included. You
> > can also try defining VC_EXTRALEAN to further reduce dependencies.
> 
> That's not a realistic use case, though. Some apps define these macros, many don't. If we're trying to get better Windows compatibility, we need to handle all of windows.h. 
> 
> 
> 
> 
> > Example:
> > 
> > // test.c
> > #define WIN32_LEAN_AND_MEAN
> > #define VC_EXTRALEAN
> > #include <Windows.h>
> > 
> > - Jesse
> > 
> > On Sun, 2010-08-08 at 09:34 -0400, Francois Pichet wrote:
> >> Hi,
> >> 
> >> Read this if you are interested in CLang compatibility with MSVC.
> >> 
> >> Today I did some testing compiling just <windows.h> in C and C++ mode
> >> using CLang.  (Let's forget MFC)
> >> Note that including <windows.h> pulls close to 80000 lines of C/C++ declaration.
> >> I used the <Windows.h> bundled with Visual Studio 2008 (SDK v7.0A).
> >> BTW the <Windows.h> coming with the MinGW package is compiling fine
> >> but that's to be expected I think.
> >> 
> >> I created a file "test.c" containing just 1 line:
> >> #include "Windows.h"
> >> 
> >> Then I compiled in C mode and C++ mode using
> >> clang -I"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include"
> >> -D_MSC_VER=1500 -Wno-missing-declarations -Wno-invalid-token-paste
> >> -Wno-unused-value -x c test.c
> >> and
> >> clang -I"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include"
> >> -D_MSC_VER=1500 -Wno-missing-declarations -Wno-invalid-token-paste
> >> -Wno-unused-value -x c++ test.c
> >> 
> >> _MSC_VER=1500 emulate MSVC 2008.
> >> 
> >> 
> >> In C mode there are only 2 kinds of error:
> >> 1- MSVC allows typedef redefinition with a different type, CLang doesn't.
> >> 2- CLang flags this as a error:
> >>            typedef struct tagPROPVARIANT PROPVARIANT;
> >>            void foo(PROPVARIANT a[]);         <====== array has
> >> incomplete element type 'PROPVARIANT'
> >> (both cl.exe and gcc.exe accepts foo prototype, note that
> >> tagPROPVARIANT is actually undefined at this point)
> >> 
> >> 
> >> In C++ mode there are only 3 kinds of error:
> >> 1- MSVC allows typedef redefinition with a different type, CLang
> >> doesn't. (same thing as in C mode)
> >> 2- CLang doesn't recognize the __uuidof operator.
> >> 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.
> >> 
> >> 
> >> CLang is actually very close to be able to handle the core Windows
> >> system headers as provided by Microsoft.
> >> Should I report these as bugs?
> >> Is CLang being able to parse the Windows SDKs core headers a worthwhile goal?
> >> _______________________________________________
> >> cfe-dev mailing list
> >> cfe-dev at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> > 
> > 
> > _______________________________________________
> > 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