vscode-cpptools
vscode-cpptools copied to clipboard
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit
Hello,
I just intall "Visual Studio Code" to build my 3D printer firmware, I load the folder, install "PlatformIO IDE" (which install "C/C++ for Visual Studio Code"). When opening my *.h files I have an error "#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit", I look for more than 2h on internet but couldn't find anything, maybe something about IntelliSense but I don't understand what to do.
What's going on?
@Jaggana69 Your includePath may not be configured correctly. You can run C/C++: Log Diagnostics to get more info on what is being used for configuring IntelliSense.
I was thinking that PlatformIO is supposed to write the configuration. Can you share what's inside the .vscode/c_cpp_properties.json file that should have been written to the root of your workspace folder?
EDIT: I think this is the repo where bugs with PlatformIO configuration should be opened: https://github.com/platformio/platformio-core
Thank you for your replies. To be honnest, I don't know if it's due to PlatformIO or cpptools.
Here is the content of my .vscode\c_cpp_properties.json
// !!! WARNING !!! AUTO-GENERATED FILE!
// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
//
{
"configurations": [
{
"name": "PlatformIO",
"includePath": [
"c:/Sam/3D print/Wanhao D12 300 PRO MAX/Marlin-bugfix-2.1.x/Marlin",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/libraries/SPI/src",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/libraries/Wire/src",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/cores/arduino",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/variants/mega",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/libraries/HID/src",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src",
""
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"path": [
"c:/Sam/3D print/Wanhao D12 300 PRO MAX/Marlin-bugfix-2.1.x/Marlin",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/libraries/SPI/src",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/libraries/Wire/src",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/cores/arduino",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/variants/mega",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/libraries/HID/src",
"C:/Users/samuel/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src",
""
]
},
"defines": [
"PLATFORMIO=60116",
"ARDUINO_AVR_MEGA2560",
"__MARLIN_FIRMWARE__",
"NDEBUG",
"F_CPU=16000000L",
"ARDUINO_ARCH_AVR",
"ARDUINO=10808",
"__AVR_ATmega2560__",
""
],
"cStandard": "gnu11",
"cppStandard": "gnu++17",
"compilerPath": "C:/Users/samuel/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe",
"compilerArgs": [
"-mmcu=atmega2560",
""
]
}
],
"version": 4
}
If I try to change something it's automaticly reset with those values.
The #include errors detected message only appears when the project is not configured correctly. Since PlatformIO owns this part, my intuition is that you should report this to them. The one case I can think of that may not be their fault would be if we are not mapping your header files to a valid source file (.c or .cpp). If you open any of your .c or .cpp files and still have errors, then it's definitely a PlatformIO issue. One last idea is if PlatformIO is supposed to generate any header files for you and maybe that step has not completed yet.
@Jaggana69 Yeah, seems like a PlatformIO issue to me. If you're able to find which include header is not being found and find it's location (such as via doing Go to Definition on the #include statements) you may be able to locate the include path that is incorrect or missing (or possibly an incorrect define which is triggering the wrong include path to be used).
Your C/C++: Log Diagnostics output (after doing the repro) might also show more info on what is actually used, such as the system includes we add from querying the compiler.
Have same issue. Since version 19.4 it cant find include files.
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/RimCpp/**",
"${workspaceFolder}/godot-cpp/gdextension/**",
"${workspaceFolder}/godot-cpp/include/**",
"${workspaceFolder}/godot-cpp/gen/include/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.22621.0",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
@RonYanDaik By 19.4, I assume you mean 1.19.4, right? When you do C/C++: Log Diagnostics, do you see ${workspaceFolder} being missing? It's supposed to be used from ${workspaceFolder}/**. Does adding an extra ${workspaceFolder} fix it or replacing ${workspaceFolder}/** with ${workspaceFolder}?
@sean-mcmanus I've switched to 1.25.3
and it looks like it tries to look everything that is defined as #include <asdas> in the users directory?
For some reason it knows about defs.hpp (which is inside rid.hpp) and does not know rid.hpp
Logs says that it can find directory correctly:
Processing folder (recursive): D:\blahblah\mydirs\THERIMRTS\GDEXTENSION
In the logs cant find no line that has workspaceFolder mentioned.
changing between ${workspaceFolder}/** with ${workspaceFolder} does nothing.
I've changed path to '${workspaceFolder}' so now logs spams some info about these 2 files only. 'tower_defense.h' is only file that is opened right now:
LSP: (invoked) cpptools/getFoldingRanges: file:///d%3A/YurasGarbage/Godot%20Projects/Yuri-Godot-Projects/TheRimRTS/gdextension/RimCpp/src/flecs_module/tower_defense.h (id: 23)
LSP: (received) cpptools/getFoldingRanges: file:///d%3A/YurasGarbage/Godot%20Projects/Yuri-Godot-Projects/TheRimRTS/gdextension/RimCpp/src/AbilitiesManager/ImpAbilityBase.cpp (id: 24)
Does adding an extra ${workspaceFolder} fix it
Not sure what it means. If you are reffering to me having multiple "${workspaceFolder}/RimCpp/**", "${workspaceFolder}/godot-cpp/gdextension/**", I was just desperate to make it work. solved by finding version '1.19.4' where it works and seems like ${workspaceFolder}/** is enough for it.
I'm using Windows 10 and VSCode by the way. Don't know what is PlatformIO.
@RonYanDaik What is your workspace folder? Is it gdextension? That is the folder you want to be in your includePath. The C/C++: Log Diagnostics output would be more useful (with the repro file active) -- the other logging you're mentioning is from the C/C++ output pane and not the C/C++ Diagnostics pane. The screenshot hover message with the .vscode/extensions folder in it is really strange and should not happen and implies it's looking for files in the extension install directory when it should not.
What is your workspace folder? Is it gdextension?
Yes. gdextension. But there are some another folder inside that is also called gdextension
${workspaceFolder}/godot-cpp/gdextension/ means ..gdextension/godot-cpp/gdextension/
@RonYanDaik So what is the full path to the header that can't be found godot_cpp/variant/rid.hpp? Is the include path that is needed to resolve it not shown in the include paths section when log diagnostics is used?
Full path is ${workspaceFolder}\godot-cpp\gen\include\godot_cpp\variant\rid.hpp
So this is project folders with sources:
d---- 20/03/2025 20:55 gdTree3D
d---- 24/04/2025 20:16 godot-cpp
d---- 06/06/2025 20:32 RimCpp
d---- 20/08/2024 23:03 RimGDExt
d---- 25/06/2024 12:01 tracy
d---- 24/03/2025 01:13 voxel_planet
The output shows that it finds files if RimCpp/src/*/ and deeper recursive folders
But I can't see any mentions of files in the godot-cpp\* folders or any of voxel_planet , gdTree3D , RimGDExt, tracy
I'm looking here (not sure where else should I look at):
To clarify godot-cpp is not included in VSCode workspace project
@RonYanDaik Your repro details are different from the original issue, so it would be better for tracking purposes to create a new issue. If you're using a multi-root workspace, then ${workspaceFolder} will resolve do different folders depending on which file is active, so in your case it appears you have a RimCpp file open so that is what ${workspaceFolder} will resolve to and not the root gdextension folder. The C/C++ logging shown in your screenshot is for tag parsing of global symbols and is different from the include paths that will be used for IntelliSense, but if you intend for godot-cpp files to be tag parsed for symbols then you would need to add that as a workspace folder or as an additional path in browse.path. You might also try to switch to using a single workspace folder and using some files.exclude settings to exclude ones you don't want processed.
Folders in screenshot I've posted belong to single root which is gdextension.
Brows.path has ${workspaceFolder}/ entry too (seems that its by default).
Where do I look for C/C++: Log Diagnostics output?
@RonYanDaik From the command palette, you can run the C/C++: Log Diagnostics command (with the repro file active) and then check the C/C++ Diagnostics pane. I don't understand why godot-cpp would not be tag parsed or used as an include path if it has ${workspaceFolder}/** as an includePath -- make sure it's not ${workspaceFolder}/* or that would make it non-recursive -- the godot-cpp folder is not in your screenshot -- is it set as a files.exclude?
${workspaceFolder}/** is defined correctly.
godot-cpp is not included into project because I was expecting extension to find path to it through includePath or browse.path since it has a lot of files and I want to refer it using #include <xxx> and not relatieve #include "xxx" (and extension v.1.19.4 can find it)
you are right godot-cpp is defined in files.exclude (I think I've added it because I didn't want to see it in project it has to much files, but again it works fine in v.1.19.4 )
I thought that extension does not pays attention to files.exclude of project since it has its own settings.
I've run C/C++: Log Diagnostics and I cant see any string that has workspaceFolder (I don't know if it should, but you were asking about it before)