-
Notifications
You must be signed in to change notification settings - Fork 47
Compile with C++20 standards (formerly C++23) #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
This update configures cmake to instruct the compiler to use the C++23 standard. Most of the code was already compliant, but some changes to the range_map library were required to get it to compile on C++20 and later. Specifically, I removed the use of `allocator::rebind` which has been deprecated, and instead use `std::allocator_traits`. I also implemented a small number of code changes to make the compiler a little happier, though there is still plenty of scope to clean the code up more.
Cleans up the clang warning ``` Clangd: Implicit capture of 'this' with a capture default of '=' is deprecated ```
|
Quite the jump from C++17 to C++23. This would require rather new compilers to build, GCC 14/15 or Clang 19/20 etc (depending on what exactly gets used). Maybe C++20 would be a better more immediate target? That gets you But I don't know what this project's guidelines are for standard targets, or features (the aforementioned modules are starting to become usable, but don't expect them to work prior to GCC 15/Clang 17(?) or CMake 3.28 and they require Ninja or VS builds; Makefiles are still unsupported without handling dependencies and build commands manually). I personally don't have much of a complaint as I'm using recent GCC, Clang, and CMake versions, but it's not just me that this would affect. |
|
A very fair point, I hadn't really considered Visual Studio versions and had assumed that most people compiling this would have access to newer versions of Clang or GCC. I just ran a check and this change works fine with the standard set to C++20, which would significantly increase the compatible compiler range. |
|
yeah, i'd rather this update it to C++20, C++23 support is still quite partial in MSVC for example |
|
Agreed, I think C++20 should be the largest jump we do at this time. Plenty of good stuff in there that would help us refactor a lot of old code. |
|
Done. I've updated the PR so it'll compile with C++20. |
|
(this is just waiting on fixes to compilation on gcc/clang) |
|
I will take a look at this, at the least I'll figure out which minimum versions of GCC and Clang we need to build against. |
This update configures cmake to instruct the compiler to use the C++20
standard. Most of the code was already compliant, but some changes to
the range_map library were required to get it to compile on C++20 and
later.
Specifically, I removed the use of
allocator::rebindwhich has beendeprecated, and instead use
std::allocator_traits. I also implementeda small number of code changes to make the compiler a little happier,
though there is still plenty of scope to clean the code up more.
I made this change because I wanted to debug an issue I had on startup, which
ultimately turned out to be something trivial, but in trying to use std::print I
realised that the code was being compiled as C++17. I fixed up the code to get it
to compile, and then realised I just forgot to copy one of the pk3 files into the uzdoom
directory. I figured the work shouldn't go to waste, so I may as well raise a PR.
I tested this out by playing some
myhouse.pk3hoping it would exercise the enginefeatures enough to highlight any problems. As far as I can tell it played just fine.