Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ucosty
Copy link

@ucosty ucosty commented Oct 18, 2025

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::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.

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.pk3 hoping it would exercise the engine
features enough to highlight any problems. As far as I can tell it played just fine.

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
```
@kcat
Copy link
Contributor

kcat commented Oct 18, 2025

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 std::format, which you can build a std::print-like function with, as well as many other features (ranges, concepts, coroutines, modules, and more) without requiring as bleeding-edge of a compiler and toolchain.

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.

@ucosty
Copy link
Author

ucosty commented Oct 18, 2025

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.

@RicardoLuis0
Copy link
Contributor

yeah, i'd rather this update it to C++20, C++23 support is still quite partial in MSVC for example

@Boondorl
Copy link
Contributor

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.

@ucosty ucosty changed the title Compile with C++23 standards Compile with C++20 standards (formerly C++23) Oct 19, 2025
@ucosty
Copy link
Author

ucosty commented Oct 19, 2025

Done. I've updated the PR so it'll compile with C++20.

@RicardoLuis0
Copy link
Contributor

(this is just waiting on fixes to compilation on gcc/clang)

@ucosty
Copy link
Author

ucosty commented Oct 21, 2025

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.

@RicardoLuis0
Copy link
Contributor

according to CI just adding the missing typename keyword to the typedef should hopefully be enough
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants