Stl: Disable concepts when compiling with clang

Created on 17 May 2020  路  5Comments  路  Source: microsoft/STL

Hi there,

I'm trying the experimental clang compiler that introduces reflection/compile time metaprogramming. It requires '-std=c++2a' and 'freflection' to work correctly.

It used to work a few months ago but an update to MSVC/VS2019 means now that concepts are included (iostream is enough to cause a long chain of other headers to be included which eventually includes concepts). So now I get:

Despite the presence of some Clang-related bits, this header currently does not support Clang. You can define _SILENCE_CLANG_CONCEPTS_MESSAGE to silence this message and acknowledge that this is unsupported. 

Silencing the message with the definition still causes compiler errors.

The only way I've found to compile is by adding this to the top of the source file:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-id-macro"
#undef __cpp_concepts
#pragma clang diagnostic pop

It's okay for a little playing around but I would need to make sure I do this anywhere I include an STL header. Is there a more sane way of disabling concepts but still using c++2a/c++latest?

Thanks,
Alex

question resolved

All 5 comments

As far as I can tell the plan is to move to clang 10 soon, so that concept support is in place. @CaseyCarter might have an estimate on when that will happen

We require Clang 10 as of #708 (shipping in VS 2019 16.7's STL) and have enabled the <concepts> header for Clang; see the Changelog for more info.

Using any other version of Clang, especially an experimental branch based on an older release, is unsupported, as in "we haven't tested that" and "we probably can't spend the time necessary to help you investigate any problems you run into". (It's not that we want to discourage such experimentation - that's one of the reasons we're open source now - but our time is limited and we have to focus on our supported scenarios.)

You'll probably have better luck if you can find an experimental branch that's based on Clang 10 - that scenario would still be unsupported, but you'd probably run into fewer problems.

We require Clang 10 as of #708 (shipping in VS 2019 16.7's STL) and have enabled the <concepts> header for Clang; see the Changelog for more info.

Using any other version of Clang, especially an experimental branch based on an older release, is unsupported, as in "we haven't tested that" and "we probably can't spend the time necessary to help you investigate any problems you run into". (It's not that we want to discourage such experimentation - that's one of the reasons we're open source now - but our time is limited and we have to focus on our supported scenarios.)

You'll probably have better luck if you can find an experimental branch that's based on Clang 10 - that scenario would still be unsupported, but you'd probably run into fewer problems.

Hi Stephan,

Thanks for the info. Wasn't expecting/looking for proper support of this though was more just wondering about ways to disable concepts, thought maybe there was an undocumented way to turn them off. E.g. was wondering if there was a flag that undefined __cpp_concepts.

The version I am using self-reports as v11.0.0, so not sure where that leaves me.

I can probably just patch this line of yvals_core.h locally to get around this:

#if defined(__cpp_concepts) && __cpp_concepts > 201507L

Thanks

This might also be on topic for Clang's cfe-dev mailing list.

We _require_ Clang 10 as of #708 in VS 2019 16.7, but we _support_ Clang 10 in 16.6 preview 3 and later. (We thought that STL support for the release of Clang that we ship in-box with VS was important enough to port the necessary changes into 16.6 at the eleventh hour.) If your Clang 11 forked from trunk between when the Clang 10 release branch forked and when Clang 10 was finally released, it may not have the Concepts support and or bugfixes that were squeezed into _Clang_ at the last minute to support the STL. If it forked from trunk more recently you should be fine.

Was this page helpful?
0 / 5 - 0 ratings