Clang suddenly can't find standard headers (`iostream`, `vector`, etc.)
07:32 20 Mar 2026

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 
#include 
#include 
using namespace std;
 
vector twoSum(vector &nums, int target) {
  unordered_map 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 nums = {2, 7, 11, 13};
  int target = 18;
  vector 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 
      |          ^~~~~~~~~~
1 error generated

I 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

c++ gcc clang