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

7 answers

Sort by: Most helpful
  1. Varsha Dundigalla(INFOSYS LIMITED) 3,960 Reputation points Microsoft External Staff
    2025-12-12T11:05:13.02+00:00

    Thank you for reaching out.

    Visual Studio IntelliSense is still using the wrong compiler settings. Even though you added all the include paths and flags, IntelliSense decides which compiler to mimic based on the PATH environment in your CMake preset. If /opt/gcc-15/bin is not first in PATH, IntelliSense falls back to /usr/bin/g++ and ignores the GCC 15 macros (like _Float32), so the squiggles remain.

    1. Add PATH override in your preset In your linux-debug preset, add: "environment": { "PATH": "/opt/gcc-15/bin:${penv:PATH}" } Show more lines This makes sure Visual Studio queries GCC 15 for IntelliSense instead of the default compiler.
    2. Keep these settings you already did:
      • intelliSenseMode: "linux-gcc-x64"
      • CMAKE_EXPORT_COMPILE_COMMANDS: ON
      • copyAdditionalIncludeDirectoriesList and additionalCompilerArgs with -isystem paths.
    3. Clean and rebuild caches:
      • Close the folder in Visual Studio.
      • Delete %LOCALAPPDATA%\Microsoft\Linux\HeaderCache\1.0\Ubuntu.
      • Reopen the project → Delete Cache and ReconfigureBuild All.
    4. Verify detection: After reconfigure, check the CMake output in Visual Studio. It should show:
         C++ compiler: /opt/gcc-15/bin/g++
      
      If it still shows /usr/bin/g++, the PATH override didn’t apply.

    The missing piece is making /opt/gcc-15/bin the first entry in PATH for your preset. Without that, IntelliSense keeps using the wrong compiler macros, causing false errors.

    Please let us know if you require any further assistance, we’re happy to help.

    If you found this information useful, kindly mark this as "Accept Answer".


  2. Gade Harika (INFOSYS LIMITED) 2,175 Reputation points Microsoft External Staff
    2025-12-16T11:14:00.7933333+00:00

    Thanks for reaching out.
    I’ve updated your CMakePresets.json to explicitly set compilerPath: /opt/gcc-15/bin/g++ and queryCompilerForIncludes: true. This ensures IntelliSense queries GCC 15 for builtin and system includes, matching your build configuration. After replacing the preset, please close VS, delete the Linux header cache on Windows, remove the remote .vs folder, then Delete Cache → Reconfigure → Build All. In CMake Diagnostics, confirm CMAKE_CXX_COMPILER is /opt/gcc-15/bin/g++ and PATH begins with /opt/gcc-15/bin. With the driver pinned and caches refreshed, the _Float32 and related false positives should be gone. If anything persists, share the updated CMake Diagnostics and compile_commands.json

    Apply_Instructions (1).txt
    CMakePresets.updated1.txt

    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.