I'm on Sequoia 15.1.4.1 and I encountered almost the same problem as OP. First clang++ couldn't find <cstdint>. Then like OP I constructed a C++ snippet that included only <iostream> and clang++ couldn't find <iostream> either. I used -v to check the header search path:
I'm on Sequoia 15.1.4 and I encountered almost the same problem as OP. First clang++ couldn't find <cstdint>. Then like OP I constructed a C++ snippet that included only <iostream> and clang++ couldn't find <iostream> either. I used -v to check the header search path:
I'm on Sequoia 15.4.1 and I encountered almost the same problem as OP. First clang++ couldn't find <cstdint>. Then like OP I constructed a C++ snippet that included only <iostream> and clang++ couldn't find <iostream> either. I used -v to check the header search path:
tl;dr: Rename or if you're confident enough, delete /Library/Developer/CommandLineTools/usr/include/c++, then clang++ will automatically search headers under /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 and find your <iostream> header. That directory is very likely an artifact of OS upgrade and by deleting it clang++ will realize that it should search in the header paths of new SDKs. The same fix should apply to almost "any standardany "standard library header not found" problem as long as the header clang++ couldn't find resides under /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 but clang++ only searches /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1.
Note: Another symptom of this problem is that clangd also can't find any standard library header. I encountered this problem when I was using the VS Code Clangd extension and clangd simply refused to recognize any stdlib header without setting up a compile_commands.json or some magical incantationincantations of --query-driver, both being solutions widely suggested on the web. I didn't give it much thought back then because I believed it was only clangd, not the compilers clang and clang++, that couldn't find the headers. Maybe clangd was just more simplistic in its header search logic. Now after renaming or deleting the directory, clangd should be able to discover stdlib headers out of the box without any configuration.
The rest of this answer shows how I arrived at this solution.
tl;dr: Rename or if you're confident enough, delete /Library/Developer/CommandLineTools/usr/include/c++, then clang++ will automatically search headers under /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 and find your <iostream> header. That directory is very likely an artifact of OS upgrade and by deleting it clang++ will realize that it should search in the header paths of new SDKs. The same fix should apply to almost "any standard library header not found" problem as long as the header clang++ couldn't find resides under /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 but clang++ only searches /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1.
Note: Another symptom of this problem is that clangd also can't find any standard library header. I encountered this problem when I was using the VS Code Clangd extension and clangd simply refused to recognize any stdlib header without setting up a compile_commands.json or some magical incantation of --query-driver, both being solutions widely suggested on the web. I didn't give it much thought back then because I believed it was only clangd, not the compilers clang and clang++, that couldn't find the headers. Maybe clangd was just more simplistic in its header search logic. Now after renaming or deleting the directory, clangd should be able to discover stdlib headers out of the box without any configuration.
tl;dr: Rename or if you're confident enough, delete /Library/Developer/CommandLineTools/usr/include/c++, then clang++ will automatically search headers under /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 and find your <iostream> header. That directory is very likely an artifact of OS upgrade and by deleting it clang++ will realize that it should search in the header paths of new SDKs. The same fix should apply to almost any "standard library header not found" problem as long as the header clang++ couldn't find resides under /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 but clang++ only searches /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1.
Note: Another symptom of this problem is that clangd also can't find any standard library header. I encountered this problem when I was using the VS Code Clangd extension and clangd simply refused to recognize any stdlib header without setting up a compile_commands.json or some magical incantations of --query-driver, both being solutions widely suggested on the web. I didn't give it much thought back then because I believed it was only clangd, not the compilers clang and clang++, that couldn't find the headers. Maybe clangd was just more simplistic in its header search logic. Now after renaming or deleting the directory, clangd should be able to discover stdlib headers out of the box without any configuration.
The rest of this answer shows how I arrived at this solution.
Note: Another symptom of this problem is that clangd also can't find any standard library header. I encountered this problem when I was using the VS Code Clangd extension and clangd simply refused to recognize any stdlib header without setting up a compile_commands.json or some magical incantation of --query-driver, both being solutions widely suggested on the web. I didn't give it much thought back then because I believed it was only clangd, not the compilers clang and clang++, that couldn't find the headers. Maybe clangd was just more simplistic in its header search logic. Now after renaming or deleting the directory, clangd should be able to discover stdlib headers out of the box without any configuration.
Note: Another symptom of this problem is that clangd also can't find any standard library header. I encountered this problem when I was using the VS Code Clangd extension and clangd simply refused to recognize any stdlib header without setting up a compile_commands.json or some magical incantation of --query-driver, both being solutions widely suggested on the web. I didn't give it much thought back then because I believed it was only clangd, not the compilers clang and clang++, that couldn't find the headers. Maybe clangd was just more simplistic in its header search logic. Now after renaming or deleting the directory, clangd should be able to discover stdlib headers out of the box without any configuration.