I have Apple clang, as well as homebrew gcc installed. In neovim, i have set up the clangd lsp, which works fine as it is, but when i try to use bits/stdc++.h library, i get linting errors everywhere.
For reference, this is my neovim config: https://github.com/AnshUjlayan/nvim
I created a new std file here: /usr/local/include/bits/stdc++.h
my include file points here: /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/iostream (i think is supposed to be inside clitools/usr, idk why it ponts here, theres also no include files for cpp in my usr folder, i have reinstalled xcode cli tools multiple times but no fix)
when i open it in vscode, theres no linting issue, all imports are valid, i can even run it (using clang and gcc both, but the library imports are from apple clang)
this is my c_cpp_properties.json:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-arm64"
}
],
"version": 4
}
Linting errors in nvim:
nvim bits/stdc++.h linting error
I fixed this issue a long time ago, by deleting the clangd binary inside ~/.local/share/nvim/mason/bin, and creating a symlink to /usr/bin/clangd. this resolved the issue. but when i updated the mac, i got the same linting errors. So i repeated the same steps again, now i have a different problem, idk what cpp standard it’s using this time:
nvim linting error
in vscode, no linting errors but running gave issues:
[Running] cd "/Users/anshujlayan/Documents/CodeForces/" && g++ main.cpp -o main && "/Users/anshujlayan/Documents/CodeForces/"main
main.cpp:9:15: error: non-aggregate type 'vector<long long>' cannot be initialized with an initializer list
vector<int> vec = {1, 2, 3, 4, 5};
^ ~~~~~~~~~~~~~~~
main.cpp:10:8: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (auto i : vec)
^
main.cpp:10:15: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (auto i : vec)
^
2 warnings and 1 error generated.
[Done] exited with code=1 in 0.513 seconds
this works, but i wanted to know if there is a way i can use stdcpp
4