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/.
Related
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
}
I am using vs code on macOs and I have this error.
I searched all the solution. It points me to configure the include path.
I tried to use below code in the terminal
clang++ -v -xc++ -
to get where the include search start.And I got this information.
So I include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include into the configuration json like below.
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"${/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include}/**"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-arm64"
}
],
"version": 4
}
But vscode tells me that it cannot find this path. Is there anything that I did wrong? How can I fix the includePath error on macOS?
Underneath I have listed my c_cpp_properties.json file, when I remove the Linux config it works just fine on windows 10. But I would like to know if there is a way to make it that vscode on windows can ignore the Linux config. Because I'd like to be able to sync with different devices.
"configurations": [
{
"name": "Win32",
"includePath": [
" ${workspaceFolder}/**",
"E:\\msys64\\mingw64\\include"
],
"defines": [],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "E:\\msys64\\mingw64\\bin\\gcc",
"intelliSenseMode": "${default}",
"browse": {
"path": [
"E:\\pt3/**",
"E:\\msys64\\mingw64\\include\\**"
],
"limitSymbolsToIncludedHeaders": true
},
"cppStandard": "gnu++17",
"compilerArgs": [],
"mergeConfigurations": false
},
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cppStandard": "c++20",
"intelliSenseMode": "linux-gcc-x64",
"browse": {
"path": [
"${workspaceFolder}",
"/usr/bin/include/**"
],
"limitSymbolsToIncludedHeaders": true
},
"configurationProvider": "ms-vscode.makefile-tools",
"compilerArgs": [],
"mergeConfigurations": false
}
],
"version": 4
}```
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?
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.