IntelliSense doesn't work properly with MSVC standard library and clang-cl compiler

Misha Kobzar 20 Reputation points
2025-10-11T04:24:39.1533333+00:00

I'm trying to get clang-cl (the compiler I installed via Visual Studio Installer) and IntelliSense to work together.

Simple 'Hello world' by C++23 std::println does build and run nicely (even macro __cplusplus is equal to 202302 which indicates that I compiling with clang-cl) but IntelliSense telling me something like 'namespace "std" has no member "println"' (I do include it's header).

I use CMake with CMake Presets.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.15...4.0)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED True)

project(
    first_probe VERSION 1.0
    DESCRIPTION "Very nice first project!"
    LANGUAGES CXX
)

add_executable(hello "src/hello.cc")

Clang part of CMakePresets.json:

{
    "version": 3,
    "configurePresets": [
        {
            "name": "clang-base",
            "hidden": true,
            "binaryDir": "${sourceDir}/build/bin/${presetName}",
            "cacheVariables": {
                "CMAKE_CXX_COMPILER": "clang-cl"
            },
            "vendor": {
                "microsoft.com/VisualStudioSettings/CMake/1.0": {
                    "intelliSenseMode": "windows-clangcl-x64"
                }
            }
        },
        {
            "name": "clang-debug",
            "displayName": "Clang - Debug",
            "inherits": "clang-base",
            "cacheVariables": {
                "CMAKE_BUILD_TYPE": "Debug"
            }
        },
    ]
}

src/hello.cc:

#include <print>

int main() {
  std::println("{0}", __cplusplus);
}

How to be able to use C++23 standard library with Clang compiler and CMake?

{02241FCA-A6E8-4528-BBFA-12F405FB6B86}

Thank you!

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Adiba Khan 895 Reputation points Microsoft External Staff
    2025-10-14T10:43:03.8833333+00:00

    Thanks for reaching out. This is a known issue that can occur when the IntelliSense engine, which is often based on the MSVC compiler’s headers, doesn’t fully align with the specific headers and libraries used by an alternative compiler like Clang. While your project is compiling and running correctly(indicating clang-cl does support C++23 features and the standard library implementation), IntelliSense is having trouble locating or correctly interpreting the definitions.

    Here is the recommended solution and a detailed explanation of why this happens and what you can do.

    Solution: Adjusting IntelliSense Mode and Includes

    The primary solution is to explicitly guide Visual Studio’s IntelliSense to use the configuration most compatible with you clang-cl setup.

    1.      Correct the IntelliSenseMode in CMakePresets.json

    You are already using CMakePresets.json, which is te correct place to configure this, In your existing “clang-base” preset, change the IntelliSenseMode to one that is more compatible with a pure Clang-based environment, even though you are using Clang-cl.

    Change this:

                  “intellisenseMode” : “windows-clangcl-x64”

    To this:

                  “intellisenseMode” : “clang-x64”

    The clang-x64 mode often provides a more robust IntelliSense experience for Clang’s headers and features, which can sometimes better handle newer C++ standards than the “windows-clangcl” mode.

    2.      Verify your standard library header includes

    The std::print function is typically found in the <print> header in C++23. While your code snippet shows #include <print>, double check that your system’s clang standard library (e.g., libc++) has the necessary headers correctly installed and locatable by IntelliSense.

    ·         Ensure: You have included the correct header for the feature

    o   For std::print:

    ·         (you already appear to be doing this , but it’s a critical check).

    3.      Clear IntelliSense Code (if necessary)

    If the above steps don’t resolve the issue, the IntelliSense engine might be holding on to old cached information.

    ·         Closed Visual Studio.

    ·         Delete the build directory (e.g., out/build/). This forces a complete rebuild and cache regeneration.

    ·         Re-open visual studio and allow CMake to reconfigure.

    Understanding the Root Cause

    The issue you are seeing, “namespace “std” has no member “print”” is a classic IntelliSense problem when using non-MSVC compilers, even when the project builds successfully.

    1.      Split Personality: Your project builds using the clang-cl compiler, which correctly uses the C++23 standard library implementation (likely libc++ or a sufficiently up-to-date libstdc++) that does include std::print. This is why your build succeeds and __cplusplus is correct.

    2.      IntelliSense Divergence: Visual Studio’s IntelliSense is a separate tool. It is often configured to parse headers based on the MSVC compiler’s standard library headers by default, or it attempts to interpret the Clang headers.

    3.      The Mismatch: if the IntelliSense engine can’t correctly locate the specific Clang/libc++ headers that define std::print, or if the headers it does find are outdated or misinterpreted under the windows-clangcl setting, it will flag the code as an error, even though the compiler is fine. Changing to “IntellisenseMode” : “clang-x64” helps guide IntelliSense to a more generic and often better maintained path for Clang header compatibility.

    Please try these steps and let us know if the issue persists! If you find this helpful, please mark this as answered.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.