[LLVMdev] C++14 support for shared_mutex
Edward Diener
eldlistmailingz at tropicsoft.com
Mon Jun 8 21:49:16 PDT 2015
On 6/9/2015 12:15 AM, Stefanus Du Toit wrote:
> On Mon, 8 Jun 2015 at 20:57 Edward Diener
> <eldlistmailingz at tropicsoft.com <mailto:eldlistmailingz at tropicsoft.com>>
> wrote:
>
> How can I tell at compile time through predefined macros whether libc++
> includes/supports the C++14 header file shared_mutex ?
>
>
> If you just want to see whether the header exists, and are using Clang
> or GCC 5, you can use __has_include:
>
> http://clang.llvm.org/docs/LanguageExtensions.html#include-file-checking-macros
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__clang.llvm.org_docs_LanguageExtensions.html-23include-2Dfile-2Dchecking-2Dmacros&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=OBReYKDPkf2rIiHX9dCaocBlBS1aWqjyHfv96KXGjfE&s=yjq9jFWbl69Ob-COO8Wa4Pjq1ERvEIh_s0BHGssfbr0&e=>
Amusingly I see a shared_mutex header file for gcc 4.9. But I would need
GCC 5 to tell me it exists using the include file checking macros at
compile time. And which version of clang would I need to use that facility ?
Shouldn't this be a libc++ problem to solve ? After all the potential
shared_mutex can be or not be part of libc++, and libc++ was designed,
was it not, to be potentially used by any compiler. So relying on a
particular compiler to tell me what libc++ should be telling me, seems
not a good design.
I notice libc++ has a _LIBCPP_VERSION macro. Couldn't libc++ at least
document somewhere that for any given version _LIBCPP_VERSION it
supports some given list of libraries ? That would be sensible in my
mind. Then what it supports is independent of the compiler which uses it.
>
> Given that I have identified that libc++ is being used, will this
> work ? :
>
> #if __cplusplus >= 201402
> // Header file shared_mutex supported
> #endif
>
> or do I need to check something else ?
More information about the llvm-dev
mailing list