I just switch from an x86-64 architecture to a MacOS M1 (arm64).
I have a project that was compiling fine using gcc on ubuntu and I decided to try compiling the same project with clang on my Mac. (Both using CPP17)
There is some warnings which is ok but I noticed every include using <experimental/source_location> are indeed available on gcc/include directory but are not existent on llvm/include/c++ (not standard, not experimental either)
I tried using clang 14.0.0 (included in Xcode) and with clang 15 installed via homebrew, both did not include source_location.hpp at all.
Do you know why it’s not available for llvm ? Do I think to add it manually or replace by something else ?
I can’t find any documentation regarding this.
libc++ C++20 Status — libc++ documentation documents that the standardised-in-C++20 <source_location> is not yet done, presumably because it was never implemented previously as an experimental feature.
will help you to find the version of your installed libc++. On my MacBook, I have version 14. LLVM just shipped version 15.06 and is on the way to branch version 16.
So as I understand there’s no source_location class or header available neither in experimental or in standard for clang C++ right now. Do you have any idea if there is an equivalent in clang that will allow me to replace ?
The Clang 16 release will implement std::source_location (usable in C++20 and later).
I do not recommend attempting to use __builtin_source_location in your own code, as it actually requires std::source_location::__impl type to be defined, which only the standard library is allowed to do.
You could use __builtin_LINE, __builtin_FUNCTION, __builtin_FILE instead.