5

Yesterday I upgraded my Command Line Tools to version 14.2, and my macOS version to Ventura 13.1.

When I tried to include bits/stdc++.h inside a C++ file and compile it, it gave me this error:

fatal error: assert.h: No such file or directory
   44 | #include <assert.h>
      |          ^~~~~~~~~~

The error clearly seems to originate from the missing assert.h file (along with some others, such as ctype.h).

I checked my /usr/include directory, and it does appear that the assert.h file does not exist.

I am using g++12 which I installed from homebrew. I tried reinstalling g++ and command line tools, but that did not help. Also, before upgrading my command line tools, everything worked fine. What can I do to fix this?

3
  • I don't even have /usr/include on Ventura. Running locate /assert.h gives me a long list of hits, both in /Applications/Xcode.app and in /Library/Developer. Do you see assert.h there?
    – nohillside
    Dec 24, 2022 at 10:49
  • 2
    Who advised you to use bits/stdc++.h in the first place? Surely that must lead to more breakage than this?
    – pipe
    Dec 24, 2022 at 15:46
  • Note that bits/stdc++.h is gcc-only. As in "GNU GCC", neither "Apple Clang posing as gcc/g++", nor "LLVM Clang from Homebrew". More specifically, it's libstdc++ only (GNU implementation of the standard C++ library), not libc++.
    – yeputons
    Dec 24, 2022 at 17:37

1 Answer 1

3

g++ worked fine again after a while, without me doing anything; this is definitely weird. I did not restart the computer or change any settings.

I've also had this strange error happen to me a few times before (each time after upgrading my OS or Xcode), where the issue just seemed to disappear each time. This might be a minor bug in the Command Line tools.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .