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

Jens Restemeier via cfe-users cfe-users at lists.llvm.org
Tue Jan 28 08:21:57 PST 2020


Hi,
I'm trying to resurrect an open source C++ reflection tool (https://github.com/Celtoys/clReflect ) against the latest clang. I've got everything building and the tool produces some output, though I've yet to analyse if the generated database is complete and correct. 

I'm trying to build with Visual Studio 2017 on Windows 10.

I'm having a hard time getting the compiler settings correct to parse Microsoft's Visual C headers, as most documentation is relative to the command line.

First of all, what is the correct/official way to set lang_options.MSCompatibilityVersion? clang::LangOptions::MSVC2017 by itself doesn't seem to make a difference, one comment online seems to suggest a scale factor, though it is odd that I can't find a macro or constant for this.

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
2>    #if _CRT_INTERNAL_NONSTDC_NAMES"
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.

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;"

I've got
"	lang_options.MicrosoftExt = 1;
	lang_options.MSVCCompat = 1;
	lang_options.DeclSpecKeyword = 1;
"
are there any more options to enable Microsoft-specific extensions?

Cheers,
Jens


More information about the cfe-users mailing list