#if __cplusplus < 201703L
#error "__cplusplus is not C++17"
#endif
#if _MSVC_LANG < 201703L
#error "_MSVC_LANG is not C++17"
#endif
int main()
{
try { } catch (...) { };
return 0;
}
I tried the following combinations:
>clang-tidy foo.cpp -- cl /GR /EHsc /std:c++17
C:\...\foo.cpp:2:2: error: "__cplusplus is not C++17" [...]
#error "__cplusplus is not C++17"
^
C:\...\foo.cpp:5:2: error: "_MSVC_LANG is not C++17" [...]
#error "_MSVC_LANG is not C++17"
^
>clang-tidy foo.cpp -- cl -GR -EHsc -std:c++17
error: unknown argument: '-EHsc' [...]
error: unknown argument: '-std:c++17' [...]
C:\...\foo.cpp:2:2: error: "__cplusplus is not C++17" [...]
#error "__cplusplus is not C++17"
^
C:\...\foo.cpp:5:2: error: "_MSVC_LANG is not C++17" [...]
#error "_MSVC_LANG is not C++17"
^
>clang-tidy --extra-arg-before=--driver-mode=cl foo.cpp -- cl /GR /EHsc -std:c++17
C:\...\foo.cpp:10:3: error: cannot use 'try' with exceptions disabled [...]
try { } catch (...) { };
^
>clang-tidy --extra-arg-before=--driver-mode=cl foo.cpp -- cl -GR -EHsc -std:c++17
(works)
Without --extra-arg-before=--driver-mode=cl, /std:... is accepted but does nothing. With --extra-arg-before=--driver-mode=cl, only the cl option forms starting in - instead of / seem to work.
It does not seem possible to invoke clang-tidy with a
cl
command line that uses slash-style options:I tried the following with clang-tidy 7 and 10.
With a source
foo.cpp
:I tried the following combinations:
Without
--extra-arg-before=--driver-mode=cl
,/std:...
is accepted but does nothing. With--extra-arg-before=--driver-mode=cl
, only thecl
option forms starting in-
instead of/
seem to work.