On Sunday 29 September 2013 12:59:27 Edward Diener wrote:
First off I am not of course proposing any changes to the upcoming release build of Boost 1.55 for clang under Windows.
It turns out that clang under Windows, possibly to support the ability to use Windows header file, becomes another compiler which defines _MSC_VER. I believe the Intel compiler also does this but there may be some others.
However clang is a much more strictly conforming to the C++ standard compiler than VC++ and does not have VC++'s quirks. This presents a problem in Boost.
The Boost header files have numerous places where testing the macro _MSC_VER produces slightly different behavior based on the fact that the code is being used by VC++ or a compiler with the same behavior as VC++. But clang does not have the same behavior as VC++ despite defining _MSC_VER.
Can I go ahead and change some of these situations as necessary to get clang under Windows to work properly with Boost code ?
The usual change will be to test not only _MSC_VER but also that __clang__ is not defined for keeping the current implementation which assumes a VC++ compatible compiler with VC++ behavior. I am willing to make those changes in 'trunk' and keep an eye out for any significant failures in unit tests for our current regression tests.
I have already made a slight change to Boost PP config.hpp on 'trunk' so that clang for Windows will pass the preprocessor tests. I am willing to work on other changes but I do not want to go ahead and do so if the maintainers of other libraries see any reasons for me not making the changes on 'trunk'. Of course I will test any changes I make locally to make sure they do not affect any other _MSC_VER defined compilers as well as with VC++. But the changes themselves should be fairly simple, just adding a check that __clang__ is not defined as part of the VC++ type behavior. Obviously something like the many tests for _MSC_VER in order to specify #pragma once will not change but some other situations will to exclude clang from the _MSC_VER functionality.
Sorry, I haven't been following the discussion about Clang on Windows closely, but as I understand, it is in an early stage of development, isn't it? I think someone said it is not able to compile even the simplest "hello world" code samples? If so, should we add more scaffolding to Boost in order to make it work with a pre-alpha state compiler? My second concern is that Clang advertise itself as an MSVC-compatible compiler while not being one. Intel compiler, for example, also does this, but unlike Clang it is pretty close. If Clang aims to be compatible with MSVC (and I assume it does, since it defines _MSC_VER), it has to make sure it can swallow any MSVC-specific code. For this reason I would prefer Boost code not to be adjusted for Clang, but rather the other way around. If someone is willing to push Clang on Windows forward, I think reporting bugs to Clang team is more appropriate than adjusting software for it.