Closed f8e85f34-88d0-4ec5-bbf1-7aa1a2a92a2e closed 1 year ago
Keeping _MSVC_LANG
updated has been a chronic issue. Instead of trying to emulate MSVC's exact values, it may be easier and more effective to simply define _MSVC_LANG
to be the same as __cplusplus
. (Assuming, that is, that clang never chooses to emulate MSVC's behavior that __cplusplus
is 199711L
without /Zc:__cplusplus
on the command line, which I would not recommend that you do.)
This issue seems to have been addressed by https://reviews.llvm.org/D114867 (defines _MSVC_LANG
to 202002L
in C++20 mode) and https://reviews.llvm.org/D114952 (defines _MSVC_LANG
to 202004L
in C++2b mode).
Is there any chance of getting these two patches ported to release/13.x
for 13.0.1?
Closing as this is fixed in head
@llvm/issue-subscribers-c-2b
@llvm/issue-subscribers-clang-driver
Extended Description
Currently _MSVC_LANG is defined as 201705L both in C++20 mode (/std:c++20 for clang-cl) and in C++2b mode (/std:c++latest for clang-cl). This prevents library code from discovering whether C++2b features are enabled.
The relevant code is in https://github.com/llvm/llvm-project/blob/1e11ccad837c2d0d848349e7bc8f5800e5d365fc/clang/lib/Basic/Targets/OSTargets.cpp#L183-L190 :
For the reference, MSVC 2022 preview 3 (latest MSVC as of now) uses 202002L for C++20 and 202004L for C++2b.