IntelliSense not finding any header or symbol - visual-studio-code

I am using VS Code v1.75.1 on Windows 10 Pro. I need to navigate a huge project in C++.
I have installed the following extensions (all enabled)
C/C++
C/C+++ Extension Pack
C/C++ Themes
CMake
CMake Tools
Dev Containers
Docker
The relative block for IntelliSense in c_cpp_properties.json reads as
"name": "Win32",
"includePath": [
"${workspaceFolder}",
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"browse": {
"path": [
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "msvc-x64"
and I assure that all the headers are under ${workspaceFolder}. The same configurations files are working properly on Linux OpenSUSE v15.4 (meaning that I am able to navigate the same exact source code). In that case the relative block in c_cpp_properties.json reads as reads as
"name": "Linux",
"includePath": [
"/usr/local/include/**",
"/usr/include/**",
"/usr/include/linux",
"${workspaceFolder}/**"
],
"defines": [],
"browse": {
"path": [
"/usr/local/include",
"/usr/include",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"configurationProvider": "vector-of-bool.cmake-tools",
"compileCommands": "${workspaceFolder}/compile_commands.json"
But, the problem is, this block is not working in a Docker Container with OpenSUSE v15.3 on the native Windows machine!
How can I solve this issue?
(Sorry if I have not included relevant information - it is the first time I use VS code).
I even tried to add a single include folder to includePath, but IntelliSense refuses to follow any symbol I give. I can't even follow #include <vector>!

Related

How to build a project with CMake and MinGW using Visual Studio Code?

I found an instruction on how to use VS Code with MinGW, but can't figure out how to use it with my project that have CMakeLists.txt.
Should I use a plugin like CMake Tools in addition to C/C++ extension used in the instruction?
E. g. assume I did all the steps and was able to compile hello.cpp with a configuration like this:
{
"configurations": [
{
"name": "GCC",
"includePath": ["${workspaceFolder}/**"],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/msys64/mingw64/bin/g++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
How to build my CMakeLists.txt then?
EDIT1:
Configuration provider
We can get some configuration information from ms-vscode.cmake-tools:

Visual Studio Code IntelliSense for Arduino and DxCore

Has anyone here gotten IntelliSense to work relatively flawlessly in Visual Studio Code for Arduino with DxCore projects? I've gotten most of the way, but still have some issues.
For me, any calls to Serial.printf() get marked with a red squiggly. Ctrl+clicking on printf shows me the definition just fine. Other things here and there have the same behavior. For example, va_start within the printf definition.
In addition to that, when verifying the sketch, I get:
[Error] Failed to read or write IntelliSense configuration: {}
Don't think it's a real problem, but it's annoying.
Here's my c_pp_properties.json file:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\Users\\nabel\\OneDrive\\Documents\\ArduinoData\\packages\\DxCore\\hardware\\megaavr\\**",
"C:\\Users\\nabel\\OneDrive\\Documents\\Arduino\\libraries\\**",
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**",
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\**",
"C:\\Program Files (x86)\\Arduino\\tools\\**",
"C:\\Program Files (x86)\\Arduino\\libraries\\**"
],
"forcedInclude": [
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"ARDUINO=10816", // Should be updated for version of Arduino IDE installed; https://stackoverflow.com/a/30928558
"USBCON"
],
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
If anyone has IntelliSense working well, could you share your c_pp_properties.json file? Thanks!
JSON doesn't allow javascript comments my friend! Remove it and Bob's your uncle.

How do I fix a "could not be parsed" Visual Studio Code configuration error?

I am currently setting up Visual Studio Code for C++ usage, however when setting up my compiler path in edit configuration (UI) to C:\MinGW65\mingw64\bin\g++.exe it shows up with the error :
[27/04/2021, 10:25:03 pm] "C:\MinGW64\mingw64\bin\g++.exe" could not be parsed. 'includePath' from c_cpp_properties.json in folder 'Start' will be used instead.
Note: Start is the name of current opened directory.
I have tried setting up my compiler path to: C:/MinGW64/mingw64/bin/gcc.exe, which shows up with no errors however gcc.exe as researched is a compiler that compiles mainly C.
When looking inside the visual studio code documentations and the tutorial videos, it stated to write the path to the compiler nothing more nothing less, which I have done above. I have tried to solve this error; resulted in nothing. How could I fix this error?
Error:
[27/04/2021, 10:39:24 pm] "C:\MinGW64\mingw64\bin\g++.exe" could not be parsed. 'includePath' from c_cpp_properties.json in folder 'Start' will be used instead.`
Configuration File:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${default}"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/MinGW64/mingw64/bin/g++.exe",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}

Configure VSCode include path

I use VSCode to edit Xilinx SDK files. The VSCode issues "problems" that include path can't be found.
I used the bulb "show fixes":
Add to "includePath": D:/Other/Xilinx/SDK/2017.4/gnu/aarch32/nt/gcc-arm-none-eabi/lib/gcc/arm-none-eabi/6.2.1/include
But VSCode is still complaining about the missing include path, although each Add to "includePath" adds a correct path to "c_cpp_properties.json" in the projects .vscode folder.
What's wrong with the include configuration?
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/standalone_bsp_0/ps7_cortexa9_0/include",
"D:/Other/Xilinx/SDK/2017.4/gnu/aarch32/nt/gcc-arm-none-eabi/lib/gcc/arm-none-eabi/6.2.1/include",
"D:/Other/Xilinx/SDK/2017.4/gnu/aarch32/nt/gcc-arm-none-eabi/lib/gcc/arm-none-eabi/6.2.1/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "8.1",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
That's the line complained by VSCode:
#include <stdint.h>
Edit:
Each accepting of the "fix" causes an additional line with the same path in "includePath", but this doesn't solve the problem. So what you see in the c_cpp_properties.json dump is caused by the "fix".
Your c_cpp_properties.json appears to have the same problems as in another answer I recently posted. To summarize:
Add compilerPath.
Change intelliSenseMode to gcc-x86 or gcc-x64. (Not sure which, there is no gcc-arm option.)
Check out the tutorial.
Try running "C/C++: Log Diagnostics" and "gcc -v -E -dD".
See the linked answer for a few more hints and details.

How does the C/C++ extension of Visual Studio Code find the default compiler?

I started a project and I created my c_cpp_properties.json file. I was quite surprised to find that the contents of the file showed a compiler by default:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "",
"compilerPath": "C:\\DiaSemi\\SmartSnippetsStudio\\Tools\\mingw64_targeting32\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
I was wondering how did it find that particular gcc.exe path, as even though it's installed in my computer, I've never used it, and if I had, I would have done it from the Dialog Semi IDE, not Visual Studio Code and if I had ever set a default compiler, that's probably the last one I would have chosen. I checked the settings, and for the life of me, I can't find any "default compiler" setting.
VS Code found it through a very odd include in my general path in Windows. After deleting it, new projects don't have a default compiler path.