Using clang compiler with Visual Studio

If you are writing platform indepenent code, using the clang compiler during development on a Windows platform is recommended because you are more likely to write code that can be compiled with other compilers.

There is a version which is a plug-in replacement for the Visual Studio compiler called clang-cl.exe.

To use it install Win64 LLVM from the LLVM website. For example LLVM-13.0.0-win64.exe (228MB) released on 4 Oct 2021.

The clang-cl.exe replacement for the Visual Studio compiler is typically installed here on your development machine:

    C:/Program Files/LLVM/bin/clang-cl.exe 

To use the clang compiler, simply add the following into the "variables" section of your CMakeSettings.json file:

    {
        "name": "CMAKE_CXX_COMPILER",
        "value": "C:/Program Files/LLVM/bin/clang-cl.exe"
    },
    {
        "name": "CMAKE_C_COMPILER",
        "value": "C:/Program Files/LLVM/bin/clang-cl.exe"
    },