Jeffrey Walton wrote:
> Clang got into a code path intended for MSVC.
> ...
>     #elif defined(__clang__) && defined(_MSC_VER)

We already know since 2020 [1] that

  - clang for Unix masquerades as GNU C 4.2.1, by defining
      #define __GNUC__ 4
      #define __GNUC_MINOR__ 2
      #define __GNUC_PATCHLEVEL__ 1
    So that they can #include and process system header files.

  - clang for Windows masquerades as MSVC, by defining
      #define _MSC_VER 1900
    So that they can #include and process system header files
    from MSVC. [2][3]

But it still defines __clang__ and __clang_major__ in both cases,
in the same way.

Additionally, there is 'clang-cl', which is a front-end, that
transforms command-line options in the syntax that MSVC expects,
into something clang understands. [4] But this is not useful
in the GNU build system, because we would need to use the modified
'ar-lib' and 'compile' scripts with it, and it's simpler to just
use the clang binary directly, which understands -c, -o, -O2, etc.
options.

> Microsoft is using it or offering it as an alternative.

Indeed, according to [5], Microsoft bundles clang.
Are you aware of (possibly proprietary) differences between what
Microsoft distributes and the original LLVM clang?

>     # define MSVC_CLANG_VERSION (__clang_major__ * 10000 +
> __clang_minor__ * 100 + __clang_patchlevel__)
>     # define LLVM_CLANG_VERSION  (__clang_major__ * 10000 +
> __clang_minor__ * 100 + __clang_patchlevel__)

>From the screenshot in [5] it looks like there is no difference between
the version number assigned by Microsoft and the version number from
LLVM. Right?

Bruno

[1] https://lists.gnu.org/archive/html/bug-gnulib/2020-08/threads.html
[2] https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions
[3] https://stackoverflow.com/questions/67406228/
[4] https://llvm.org/devmtg/2014-04/PDFs/Talks/clang-cl.pdf
[5] https://learn.microsoft.com/en-us/cpp/build/clang-support-msbuild




Reply via email to