How do you fix Intellisense errors in a CMake project when Visual Studio is connected to WSL:Ubuntu?

Brandon Davies-Sekle 0 Reputation points
2025-12-03T12:38:18.0166667+00:00

I am running a CMake project in Visual Studio Community 2026 and it is connected to WSL: Ubuntu. It is running the Linux Debug configuration preset. WSL is running the gcc 15.1.0 compiler.

My C++ code builds and runs fine but I get hundreds of false-positive Intellisense errors. One example is the following:

Severity Code Description Project File Line Suppression State Details

Error (active) E0020 identifier "_Float32" is undefined CppProgUbuntu - Linux Debug C:\Users\bsekl\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu\opt\gcc-15\include\c++\15.1.0\atomic 1692

It is apparent that this is happening because Intellisense is not using the correct system headers and preprocessor definitions for the target environment.

How do I fix this so that Intellisense functions properly and doesn't report false-positive errors?

Developer technologies | Visual Studio | Debugging
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2025-12-03T12:38:27+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To resolve IntelliSense errors in a CMake project while using Visual Studio connected to WSL: Ubuntu, you can follow these steps:

    1. Check CMake Configuration: Ensure that your CMakePresets.json is correctly configured. This file should specify the correct IntelliSense options, including intelliSenseMode and any necessary preprocessor definitions that match your target environment.
    2. Use the Correct Toolchain File: If you are using a CMake toolchain file, make sure it is set up properly to define the compiler and include paths that correspond to your WSL environment.
    3. Verify Include Paths: Check that the include paths in your CMake configuration are set correctly. You can do this by looking at the CMakeLists.txt file and ensuring that all necessary directories are included.
    4. System Headers: Visual Studio automatically copies system headers to provide IntelliSense. If you are experiencing issues, you may need to customize the headers included or excluded in the Visual Studio Remote Settings vendor map in CMakePresets.json.
    5. IntelliSense Mode: Ensure that the IntelliSense mode is set to match the compiler you are using. For GCC, it should typically be set to gcc-x.x where x.x corresponds to your GCC version.
    6. Check for Syntax Errors: Sometimes, syntax errors in your code can prevent IntelliSense from functioning correctly. Make sure your code is free of such errors.
    7. Restart Visual Studio: After making changes to your configuration, restart Visual Studio to ensure that all settings are applied correctly.

    By following these steps, you should be able to reduce or eliminate false-positive IntelliSense errors in your CMake project when using Visual Studio with WSL: Ubuntu.


    References:

    0 comments No comments

  2. Gade Harika (INFOSYS LIMITED) 1,870 Reputation points Microsoft External Staff
    2025-12-04T11:52:25.6233333+00:00

    Thanks for reaching out.

    he false‑positive IntelliSense errors you’re seeing are due to a mismatch between the headers/defines IntelliSense is using locally and the actual GCC/libstdc++ environment on your WSL Ubuntu. Your build is correct; IntelliSense just isn’t looking at the same system headers and flags.

    Fix:

    1. In Visual Studio, run Project → Rescan Solution to force a refresh of the Remote Header Cache from WSL (after GCC updates this is required). If needed, open Tools → Options → Cross Platform → Connection Manager → Remote Headers IntelliSense Manager and Update (or Delete then re‑download). Ensure zip is installed in the WSL distro. [devblogs.m...rosoft.com]
    2. Confirm you’re using CMake Presets with Target System = WSL: Ubuntu and select the correct Configure/Build preset for your WSL toolchain. Then Delete CMake Cache and Reconfigure. [Configure...soft Learn | Learn.Microsoft.com], [learn.microsoft.com]
    3. Drive IntelliSense from your actual compile commands: switch your WSL preset to Ninja or Unix Makefiles and add set(CMAKE_EXPORT_COMPILE_COMMANDS ON) in CMakeLists.txt. Visual Studio can use compile_commands.json to align include paths/defines/std with your real GCC build. (Note: the Visual Studio generator ignores this flag.) [cmake.org], [stackoverflow.com]
    4. If you get an IntelliSense DB write warning under \\wsl.localhost\…, accept the Fallback Location or configure one under C++ → Advanced to avoid broken browsing. After these steps, IntelliSense should stop flagging _Float32 and similar constructs in <atomic> and other headers because it will be parsing the same system headers and flags that your WSL GCC actually uses. [stackoverflow.com]

    References:

    CMAKE_EXPORT_COMPILE_COMMANDS details and generator support. [cmake.org]

    Let us know if the issue persists after following these steps. I’ll be happy to assist further if needed. If the issue has been resolved, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    0 comments No comments

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.