I just upgraded to use Xcode 26.2 with AppleClang 17 and noticed that Xcode-based debug builds now generate the following warnings:
In file included from <built-in>:1:
[1m<command line>:1:9: [0m[0;1;35mwarning: [0m[1m'_LIBCPP_HARDENING_MODE' macro redefined [-Wmacro-redefined][0m
1 | #define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEBUG[0m
| [0;1;32m ^
[0mIn file included from /Users/steve/XcodeProjects/RBDOOM-3-BFG/neo/idlib/math/Vector.cpp:1:
In file included from /Users/steve/XcodeProjects/RBDOOM-3-BFG/neo/idlib/precompiled.h:34:
In file included from /Users/steve/XcodeProjects/RBDOOM-3-BFG/neo/idlib/sys/sys_includes.h:121:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.2.sdk/usr/include/c++/v1/stdlib.h:79:
[1m/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.2.sdk/usr/include/c++/v1/__config:140:13: [0m[0;1;36mnote: [0mprevious definition is here[0m
140 | # define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEFAULT[0m
| [0;1;32m ^
[0m1 warning generated.
This happens because Xcode 16.3+ is setting it's own values for llvm's (clang) _LIBCPP_HARDENING_MODE, but RBDoom3BFG's precompiled header flags don't know about that and use a conflicting platform default value (off). The solution is to assert consistent defaults in the CMAKE_CXX_FLAGS_* variables when building with Xcode and AppleClang >= 17.
Note this does not happen with command-line builds (macOS or linux) that use modern clang/llvm versions since the platform defaults for libc++ hardening are used in that case, and no conflict arises with PCH-enabled builds. Currently this happens only with Xcode since it is setting different values versus the platform defaults (e.g. using _LIBCPP_HARDENING_MODE_DEBUG for debug builds). This potentially could happen with other IDEs/platforms that use llvm version 18+ (e.g. linux), but I am not aware of other examples at the moment.
I will push a PR to fix this for Apple.
I just upgraded to use Xcode 26.2 with AppleClang 17 and noticed that Xcode-based debug builds now generate the following warnings:
This happens because Xcode 16.3+ is setting it's own values for llvm's (clang)
_LIBCPP_HARDENING_MODE, but RBDoom3BFG's precompiled header flags don't know about that and use a conflicting platform default value (off). The solution is to assert consistent defaults in theCMAKE_CXX_FLAGS_*variables when building with Xcode and AppleClang >= 17.Note this does not happen with command-line builds (macOS or linux) that use modern clang/llvm versions since the platform defaults for libc++ hardening are used in that case, and no conflict arises with PCH-enabled builds. Currently this happens only with Xcode since it is setting different values versus the platform defaults (e.g. using
_LIBCPP_HARDENING_MODE_DEBUGfor debug builds). This potentially could happen with other IDEs/platforms that use llvm version 18+ (e.g. linux), but I am not aware of other examples at the moment.I will push a PR to fix this for Apple.