I was trying to switch my Vscode from msys2 gcc to msys2 clang. I have downloaded clang according to the msys2 documentation provided. I have also followed the visual studio documentation for setting up clang. But my visual code fails to recognize iostream header.
I updated my environment path:
I also updated required include paths in my vs code configuration files:
cpp_properties:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceRoot}",
"C:/msys64/clang64/include",
"C:/msys64/clang64/include/**",
"C:/msys64/clang64",
"C:/msys64/clang64/include/c++/v1",
"C:/msys64/clang64/lib/clang/14.0.4/include",
"C:/msys64/clang64/lib/clang/14.0.4/include/**",
"${workspaceFolder}/**",
"C:/msys64/clang64/bin",
"C:/msys64"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:/msys64/clang64/bin/clang++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"C:/msys64/clang64/include",
"C:/msys64/clang64/include/**",
"C:/msys64/clang64/include/c++/v1",
"C:/msys64/clang64/lib/clang/14.0.4/include",
"C:/msys64/clang64/lib/clang/14.0.4/include/**",
"${workspaceRoot}",
"C:/msys64/clang64/bin",
"C:/msys64"
],"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
Still i keep getting the following error:
Related
i am trying to use vscode and the arduino-cli. The extension is working correctly in veryfing and uploading the code to the board but it keeps highlighting arduino keywords (e.g.: digitalWrite) as errors, and as far as i can tell this should not happen.
I am going to attach the arduino.json, c_cpp_properties.json files in because i read that the problem may lay here.
arduino.json:
{
"sketch": "first.ino",
"configuration": "cpu=atmega2560",
"board": "arduino:avr:mega",
"port": "COM5"
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\MinGW\\bin\\gcc.exe",
"cStandard": "c89",
"cppStandard": "c++98",
"intelliSenseMode": "windows-gcc-x86"
}
],
"version": 4
}
Have you tried adding the paths of all libraries your Arduino IDE program comes with? Notice the line with the forcedInclude instruction that points to the path of the Arduino.h file.
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/EEPROM/src",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/HID/src",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/SoftwareSerial/src",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/SPI/src",
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/Wire/src"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"ARDUINO_AVR_UNO",
"ARDUINO_ARCH_AVR"
],
"compilerPath": "C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc.exe",
"forcedInclude": [
"C:/Program Files (x86)/Arduion/hardware/arduino/avr/cores/arduino/Arduino.h"
],
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
I am preparing to develop a cross-platform project with CMake and so I used Cmake Tools and it created following compilerPaths:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c18",
"cppStandard": "c++20",
"intelliSenseMode": "clang-x64",
"configurationProvider": "ms-vscode.cmake-tools",
"compilerArgs": [],
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true
}
},
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe",
"cStandard": "c18",
"cppStandard": "c++20",
"intelliSenseMode": "msvc-x64",
"compilerArgs": [],
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true
}
}
],
"version": 4
}
In PROBLEMS tab I see Cannot find "\usr\bin\gcc". and that's obvious, because I am on Windows, but
the name values Linux and Win32 have some special meanings and
the paths have not been generated by me, but automatically so
I would expect the "PROBLEM" should not be there.
So how to correctly fix the "PROBLEM"?
You just need to switch the config.
On the bottom right it should say Linux (the name of the config).
Click on Linux and switch to Win32.
I got the same error on Windows when my config was set to Linux. When switching to the Win32 config I get no error.
I am using visual studio code for c++ programming. Whenever I run my program, it gives me the following error:
include errors detected.
Please update your includePath.
Squiggles are disabled for this translation unit
(/home/yash_j1301/Documents/GitHub/C++ Workspace/yash1.cpp).
I am using Ubuntu 19.04 Disco Dingo and quite new to c++ programming. On the internet, I found some solutions like giving the path to the header files and I did that but still it is showing me errors. I already have installed and updated all the c/c++ extensions for the same.
Any idea where it is going wrong? I have already attached the screenshot for the error.
Here is my c_cpp_properties.json file code:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/home/yash_j1301/TC/INCLUDE/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
},
{
"name": "conf1",
"includePath": [
"/home/yash_j1301/TC/CLASSLIB/INCLUDE/",
"/home/yash_j1301/TC/INCLUDE/SYS/",
"/home/yash_j1301/TC/INCLUDE/"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
Any idea what I'm missing out?
These are the things you can do :
check if you have installed the c/c++ extension.
Check if mingw-w64 is installed (http://www.mingw-w64.org/doku.php )
right click on the import statement and add it to the path :
Here are all the details: https://code.visualstudio.com/docs/languages/cpp
I need to include jsoncpp in my visual studio code.
Is there any way to include .lib file in visual studio code?
this is my
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/*",
"${workspaceFolder}/C++Script/Dependencies/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.16299.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
I included json.h( although my compiler says it can't find the header file ) and I would like to include .lib file as well.
Can you tell me how to do that? I do know how to do this in visual studio. ( with liker )
c_cpp_properties.json is for Intellisense, you need to use tasks.json. Example:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}",
"/I",
"C:\\vcpkg\\installed\\x86-windows\\include"
],
...
}
I use Visual Studio code with the extensions "C/C++ for Visual Studio Code" (ms-vscode.cpptools) for developing simple C++ programs. I have added the configuration file cpp_properties.json to the .vscode subfolder to get intellisense support (see below). Unfortunately VS code does not honor the include path defined herein. I always get green swiggles under #include directives saying #include errors detected. Please update your includePath. ....
What's strange is, that the before mentioned error disappears when I select the correct configuration using the command C/Cpp: Select a configuration .... I have to repeat this command everytime I reopen the project. So obviously the include paths seems to be correct.
Is it possible to make VS Code or the CPP extension store the active configuration? Or is it at least possible to define a default configuration?
c_cpp_properties.json:
{
"configurations": [{
"name": "MinGW on Windows",
"includePath": [
"${workspaceRoot}",
"${MINGW_HOME}\\include\\c++\\7.1.0",
"${MINGW_HOME}\\include\\c++\\7.1.0\\x86_64-w64-mingw32",
"${MINGW_HOME}\\include\\c++\\7.1.0\\backward",
"${MINGW_HOME}\\lib\\gcc\\x86_64-w64-mingw32\\7.1.0\\include",
"${MINGW_HOME}\\include",
"${MINGW_HOME}\\x86_64-w64-mingw32\\include"
],
"defines": [],
"browse": {
"path": [
"${workspaceRoot}",
"${MINGW_HOME}\\include\\c++\\7.1.0",
"${MINGW_HOME}\\include\\c++\\7.1.0\\x86_64-w64-mingw32",
"${MINGW_HOME}\\include\\c++\\7.1.0\\backward",
"${MINGW_HOME}\\lib\\gcc\\x86_64-w64-mingw32\\7.1.0\\include",
"${MINGW_HOME}\\include",
"${MINGW_HOME}\\x86_64-w64-mingw32\\include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "clang-x64"
},
{
"name": "GCC on Linux",
"includePath": [
"${workspaceRoot}",
"/usr/include/c++/6",
"/usr/include/x86_64-linux-gnu/c++/6",
"/usr/include/c++/6/backward",
"/usr/lib/gcc/x86_64-linux-gnu/6/include",
"/usr/local/include",
"/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed",
"/usr/include"
],
"defines": [],
"browse": {
"path": [
"/usr/include/c++/6",
"/usr/include/x86_64-linux-gnu/c++/6",
"/usr/include/c++/6/backward",
"/usr/lib/gcc/x86_64-linux-gnu/6/include",
"/usr/local/include",
"/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed",
"/usr/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "clang-x64"
}
],
"version": 2
}