c++macosclanglibc++

When using clang, how can I disable libc++ availability checks?


I'm compiling C++ code in macOS 10.13 / 10.14 that makes use of features of std::filesystem that aren't normally available until macOS 10.15. As a result, I'm getting errors like this:

error: '~path' is unavailable: introduced in macOS 10.15

However, I'm linking against the static libraries of a custom-built, up-to-date version of libc++, and so these errors are irrelevant as the version of libc++ I'm using does indeed support these features, and will compile in versions of macOS prior to 10.15.

How do I disable those error messages? I'm certain there's a command line option that does it because I've used it before, but I can't for the life of me remember what it is!


Solution

  • As per documentation, you can use -nostdlib++ and -nostdinc++ to supress default stdlib include and linking paths:

    % clang++ -nostdinc++ -nostdlib++           \
              -isystem <install>/include/c++/v1 \
              -L <install>/lib                  \
              -Wl,-rpath,<install>/lib          \
              -lc++                             \
              test.cpp