[libcxx-commits] [libcxx] [libc++][test] Make macro detection more friendly to MSVC (PR #113633)

Stephan T. Lavavej via libcxx-commits libcxx-commits at lists.llvm.org
Fri Oct 25 11:26:32 PDT 2024


StephanTLavavej wrote:

This looks good to me. You could have used `TEST_COMPILER_MSVC` to recognize C1XX specifically, but detecting anyone implementing the Microsoft ABI (including Clang on Windows) also works.

clang-cl does understand these macros, so libcxx maintainers may want to use `TEST_COMPILER_MSVC` here. I observe that direct use of `_MSC_VER` is fairly rare.

```
C:\Temp>type meow.cpp
```
```cpp
#include <print>
using namespace std;

int main() {
    println("__SIZEOF_LONG_DOUBLE__: {}", __SIZEOF_LONG_DOUBLE__);
    println("__SIZEOF_DOUBLE__: {}", __SIZEOF_DOUBLE__);
}
```
```
C:\Temp>cl /EHsc /nologo /W4 /std:c++latest meow.cpp && meow
meow.cpp
meow.cpp(5): error C2065: '__SIZEOF_LONG_DOUBLE__': undeclared identifier
meow.cpp(6): error C2065: '__SIZEOF_DOUBLE__': undeclared identifier

C:\Temp>clang-cl /EHsc /nologo /W4 /std:c++latest meow.cpp && meow
__SIZEOF_LONG_DOUBLE__: 8
__SIZEOF_DOUBLE__: 8
```

https://github.com/llvm/llvm-project/pull/113633


More information about the libcxx-commits mailing list