[smartmontools-support] C++14/17 (will break compatibility)

Christian Franke Christian.Franke at t-online.de
Sat Feb 1 19:09:17 CET 2025


Christian Rosentreter wrote:
> ...
>> According to https://clang.llvm.org/cxx_status.html C++17 should be supported since Clang 5.
>>
>> The test in the configure script might return a false negative. Please test these commands:
>>
>> echo __cplusplus | g++ -E -xc++ -
>> echo __cplusplus | g++ -std=c++17 -E -xc++ -
>> echo __cplusplus | g++ -std=gnu++17 -E -xc++ -
>>
>> The last line shows the __cplusplus value, it should be 201703L if C++17 (but not C++20) is supported.
>>
> It seems that "c++17" as input value for -std isn't supported in Apple's official clang releases
> before 9.1.0. Supposedly -std=c++1z can be used (which is a [deprecated] alias for "c++17" in later
> versions, also see: https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/LangStandards.def ),
> but it only returns "201406L" in Apple's clang 7.0.2:
>
> $ echo __cplusplus | g++ -E -xc++ -
> # 1 "<stdin>"
> # 1 "<built-in>" 1
> # 1 "<built-in>" 3
> # 332 "<built-in>" 3
> # 1 "<command line>" 1
> # 1 "<built-in>" 2
> # 1 "<stdin>" 2
> 199711L
>
> $ echo __cplusplus | g++ -std=c++17 -E -xc++ -
> error: invalid value 'c++17' in '-std=c++17'
>
> $ echo __cplusplus | g++ -std=gnu++17 -E -xc++ -
> error: invalid value 'gnu++17' in '-std=gnu++17'
>
>
> $ echo __cplusplus | g++ -std=c++1z -E -xc++ -
> ...
> 201406L
>
> $ echo __cplusplus | g++ -std=gnu++1z -E -xc++ -
> ...
> 201406L
>
>
> # "C++14" is supported though, same as "-std=c++1y"
> # and is set to 201402L
> #
> $ echo __cplusplus | g++ -std=c++14 -E -xc++ -
> ...
> 201402L
>

201406 possibly indicates support for some small subset of C++17 features.

This is no problem because it is not planned to use C++17 or even C++14 
in the next releases of smartmontools.

Thanks for testing,
Christian



More information about the Smartmontools-support mailing list