#include <iostream> error in visual studio code - c++

Not sure why because it worked fine before but I get an error when trying to include in Visual Studio Code
I did add the include path to the properties.json file as in the picture but it's still not working
did i include the wrong path or is there any other solution?
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\MinGW",
"C:\\MinGW\\include",
"C:\\MinGW\bin",
"C:\\MinGW\\lib"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/MinGW/bin/gcc.exe",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "windows-gcc-x86"
}
],
"version": 4
}

Related

c_cpp_properties.json file framework error after update

I was writing code in C++ in VSCode and after I updated the software of my Mac to MacOS 12.5.1, i got an error. This is what my c_cpp_properties.json file looked like.
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}
After my update, I got this error message:
Cannot find "/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks".
Update the path in "macFrameworkPath" according to the new content of the directory
/Library/Developer/CommandLineTools/SDKs/
I would use such the config
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk always links to the actual MacOS SDK in the directory /Library/Developer/CommandLineTools/SDKs/.

Changing of c++ compiler in vs code when ever I am trying to create a new folder

So, whenever I create a new folder in vs code, the default compiler comes out to be gcc-11 but I want it to be clang.
c_cpp_properites.json file when I am trying to create a cpp file in a new folder:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [],
"compilerPath": "/usr/local/bin/gcc-11",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intellisenseMode": "macos-gcc-x64"
}
],
"version": 4
}
I have to replace my .json file code over and over again with the given code.
new c_cpp_properties.json file:
{
"configurations": [
"name": "Mac",
"includePath": [
"/usr/local/include",
"/usr/local/Cellar/gcc/11.2.0_3/include/c++/11",
"${workspaceFolder}/**",
"/usr/local/Cellar/gcc/11.2.0_3/include/c++/11/x86_64-apple-darwin21"
],
"defines": [],
"macFrameworkPath": [],
"compilerPath": "/usr/bin/clang++",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intellisenseMode": "macos-clang-x64"
],
"version": 4
}
So I want that whenever I create a new folder the vs code's default c_cpp_properties should be the second one, not the first one. Can anyone help me out to do so?

How do I put Qt in path for Visual Studio Code with Windows?

#include <QApplication>
Gives me the squiggles and compiling gives me an error.
fatal error: QApplication: No such file or directory #include <QApplication>
My c_cpp_properties.json file looks like this
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\Qt\\6.1.0\\mingw81_64\\include\\QtWidgets\\**" // line I added
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "windows-gcc-x86"
}
],
"version": 4
}
I can see that the 'qapplication.h' and 'QApplication' files are inside that QtWidgets folder that I point to. I'm confused as to why Code can't find it.
btw, QtCreator works on this machine. But I would like to use VSC instead for a couple reasons.

How to fix cannot link SDL2 image on Mac

Hi I search it up on how to do it and I did it:
c_cpp_properites.json:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/Library/Frameworks/Headers"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++98",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}
But i want to add SDL2_image too but i dont know how to do it so can someone please help me.

VS Code Include Errors Detected. "cannot open source file 'main.h' "

This questions might look similar to other questions but nothing I've tried has worked. I'm using a library called PROS for Vex robotics. I get the include detected error where it can't find the main.h file located in the workspace folder. I checked the c_cpp_properties.json to check if the folder was somehow not included.
Additionally, I tried re-installing VS code, updating the PROS library, making a new project. Nothing seems to be working, maybe I'm just overlooking a simple problem.
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/Users/cjm10000/Desktop/7701X/7701x_code/include"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"compileCommands": "${workspaceFolder}/compile_commands.json",
"browse": {
"path": [
"${workspaceFolder}/**"
]
}
}
],
"version": 4
}
Here's the folder structure and error output: