Boost logo

Boost :

Subject: Re: [boost] [build] How to use with clang on windows?
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2016-03-27 18:15:52


On 26 Mar 2016 at 6:52, Edward Diener wrote:

> The clang build which targets VC++ on Windows, as opposed to the clang
> build which targets mingw(-64)/gcc on Windows, 'emulates' the
> non-standard VC++ preprocessor so it can compile Windows API headers and
> VC++ header files. Exactly what VC++ preprocessor 'bugs' it emulates and
> how successful this emulation is I do not know, but I know it is done
> because I was told of it in the clang developer forum and I encountered
> a clang targeting VC++ preprocessor 'bug' which was explained to me as
> an emulation of VC++.

As of VS2015 Update 2 RC, the MSVCRT, STL and Windows SDK headers
supplied no longer require clang to act in MSVC compatibility mode to
compile. I am compiling AFIO v2 for windows using LLVM clang with
these options:

clang.exe -fpic "stdafx.h" -fmsc-version="1900" -std=c++1y "x64\Debug
clang\" -Wall -fstrict-aliasing -I "../include" -g2 -gdwarf-2 -O0 -x
c++-header -U "__STDC__" -D "WIN32" -D "_DEBUG" -D "_WINDOWS" -D
"_USRDLL" -D "BOOST_AFIO_EXPORTS" -D "_UNICODE" -D "UNICODE" -D
"UNICODE=1" -D "_UNICODE=1" -D "AFIO_STANDALONE=1" -frtti
-fno-omit-frame-pointer -fno-ms-compatibility -fexceptions -o
"x64\Debug clang\%(filename).obj" -fms-extensions -fno-short-enums

The key improvement with VS2015 Update 2 is the -fno-ms-compatibility
is now possible even when using the Dinkumware STL, the Parallel
Patterns Library or the Windows SDK. This means that clang treats
your code as strictly as normal, and it is *very* useful for linting
your code (the complete C++ 14 language support is also very handy).

Note that I cannot get MSVCRT-as-a-dll working with this
configuration, for that you still need -fms-compatibility.
MSVCRT-as-a-static-library is working. I assuming this is a RC
related problem which will be fixed soon, the cause is the char16_t
and char32_t support misdetection.

I am not using any preprocessor tricks which are incompatible with
MSVC, so I cannot say if the broken preprocessor emulation is still
present with -fno-ms-compatibility. I would suspect not.
-fms-extensions are things like declspec markup support, I am not
aware of it changing any parsing behaviour.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ 
http://ie.linkedin.com/in/nialldouglas/



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk