ARTICLE AD BOX
I'm facing a strange issue where **Clang/Clangd stopped recognizing standard C++ headers**, even though the same code compiles fine with GCC.
Previously this used to work and I think something broke while updating my system (OpenSUSE tumbleweed)
Code:
#include <iostream> #include <vector> #include <unordered_map> using namespace std; vector<int> twoSum(vector<int> &nums, int target) { unordered_map<int, int> mp; for (int i = 0 ; i < (int)nums.size(); i++) { int complement = target - nums[i]; if (mp.find(complement) != mp.end()) { return {mp[complement], i}; } mp[nums[i]] = i; } return {}; } int main() { vector<int> nums = {2, 7, 11, 13}; int target = 18; vector<int> result = twoSum(nums, target); cout << result[0] << " " << result[1]; }This gives the following error when I compile using clang++ (file compiles using g++)
fatal error: 'iostream' file not found 1 | #include <iostream> | ^~~~~~~~~~ 1 error generatedI also get lsp diagnostics error from clangd
No template named 'vector' No template named 'unordered_map' Use of undeclared identifier 'cout' Using directive refers to implicitly-defined namespace 'std'I tried rolling back clang to version 20 following this post.
I have no idea how to proceed further and any help is appreciated
Additional Info
OS: OpenSuSe TW
Clang version: 21
gcc version: 15
