[cfe-dev] Clang on Windows targeting VC++ preprocessor errors

Edward Diener via cfe-dev cfe-dev at lists.llvm.org
Fri Apr 15 10:11:54 PDT 2016


I am the current maintainer and partial contributor of the Boost PP ( 
Preprocessor ) library and the author/maintainer of the Boost VMD 
library. Both libraries are C++ macro libraries for making it easier to 
work with preprocessor macros.

Clang on Windows targeting VC++ ( clang-cl.exe ) attempts to emulate the 
non-standard VC++ preprocessor. In Boost PP I have set clang on Windows 
targeting VC++ ( both __clang__ and _MSC_VER are defined ) to act just 
like the VC++ preprocessor as far as Boost PP is concerned. Boost PP has 
a number of workarounds for preprocessors which do not conform correctly 
to the C++ standard preprocessor rules, among which VC++ is the largest 
culprit. These workarounds allow VC++ to compile Boost PP code, without 
which VC++ would fail because it is not a standard conforming preprocessor.

With the appropriate workarounds VC++ can compile all of Boost PP tests 
without error, although with plenty of false warnings. The false 
warnings cannot be worked around, but do not affect the final macro code.

When attempting to compile Boost PP tests with clang-cl there are a 
number of errors. I cannot report these errors to clang because I cannot 
tell where these errors are being generated from in Boost PP. The reason 
for this is that clang-cl does not show me its expansion of macros to 
the point of the error. All it tells me is that when expanding some 
higher level macro a particular preprocessor errors occurs somewhere 
lower down. Without being able to pinpoint exactly where clang is 
producing its error I cannot report clang's action as a bug in its VC++ 
emulation. Is there a solution to this in getting clang to show me where 
the error is actually occurring ?




More information about the cfe-dev mailing list