[cfe-users] Compiling Visual Studio 2017 headers with clang library

Jens Restemeier via cfe-users cfe-users at lists.llvm.org
Sat Feb 1 15:47:51 PST 2020

I got this to work, so for the benefit of future people coming across this from Google:

> I am getting 
> "C:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/ucrt\stdio.h(378,9): warning : macro expansion producing 'defined' has undefined behavior
> which is supposedly fixed by "-Wno-expansion-to-defined", though "m_DiagnosticOptions.Warnings.push_back("no-expansion-to-defined");" doesn't seem to make a difference. While I can obviously fix my own code not to use undefined behaviour, I don't want to require a change to the standard C headers that come with Windows.

This was fixed by using the second form of createDiagnostics that takes DiagnosticOptions * as the first parameter and returns a DiagnosticsEngine. My code required some extra work to handle the lifetime of the various reference counted objects correctly, but now the warning is correctly suppressed.

> And I'm getting
> "2>E:/External/clReflect/src/clReflectTest/clcppcodegen.cpp(211,7): warning : forward references to 'enum' types are a Microsoft extension
> 2>        enum NoInit;”

Somehow I had it in my head that I have to enable this extension, but apparently I have to silence the warning instead: “no-microsoft-enum-forward-reference”


More information about the cfe-users mailing list