From Clang's documentation:
When Clang compiles C++ code for Windows, it attempts to be compatible with MSVC.
In particular, Clang defines _MSC_VER
.
MSVC does not support #pragma STDC FENV_ACCESS ON
:
cl t125.c /std:c11
t125.c(11): warning C4068: unknown pragma 'STDC'
Instead MSVC does support #pragma fenv_access (on)
. This leads to this code:
#if _MSC_VER
#pragma fenv_access (on)
#else
#pragma STDC FENV_ACCESS ON
#endif
Now try to compile this code using the latest Clang on Windows:
$ /cygdrive/d/SOFTWARE/LLVM/12.0.0/bin/clang t125.c -Wall -Wextra
t125.c:10:9: warning: unknown pragma ignored [-Wunknown-pragmas]
#pragma fenv_access (on)
Meaning that since #pragma fenv_access (on)
is unknown pragma
which is ignored
, then the MSVC compatibility is underdone / unfinished? Confused.
Question: how to disable the default MSVC compatibility (so that Clang does not define _MSC_VER
)?
P.S. This finally leads to this code:
#if _MSC_VER && ! __clang__ && ! __INTEL_COMPILER
#pragma fenv_access (on) /* true MSVC here?? */
#else
#pragma STDC FENV_ACCESS ON
#endif
UPD. Patch for supporting the MS spelling of the pragma: https://reviews.llvm.org/D111440.