Enable C++23

This commit is contained in:
Daniel Wolf 2024-12-27 11:15:38 +01:00
parent 3283e66db4
commit 91390784e7
2 changed files with 11 additions and 5 deletions

View File

@ -28,10 +28,17 @@ endif()
# Support legacy OS X versions # Support legacy OS X versions
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "Minimum OS X deployment version") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "Minimum OS X deployment version")
# Enable C++17 # Enable C++23
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Disable char8_t support (see https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1423r3.html)
if(compilerIsGccOrClang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-char8_t")
elseif(compilerIsMsvc)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:char8_t-")
endif()
# Enable POSIX threads # Enable POSIX threads
if(compilerIsGccOrClang) if(compilerIsGccOrClang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")

View File

@ -7,7 +7,6 @@
#include "ogg-vorbis-file-reader.h" #include "ogg-vorbis-file-reader.h"
#include "wave-file-reader.h" #include "wave-file-reader.h"
using fmt::format;
using std::runtime_error; using std::runtime_error;
using std::string; using std::string;
using std::filesystem::path; using std::filesystem::path;
@ -21,13 +20,13 @@ std::unique_ptr<AudioClip> createAudioFileClip(path filePath) {
if (extension == ".ogg") { if (extension == ".ogg") {
return std::make_unique<OggVorbisFileReader>(filePath); return std::make_unique<OggVorbisFileReader>(filePath);
} }
throw runtime_error(format( throw runtime_error(fmt::format(
"Unsupported file extension '{}'. Supported extensions are '.wav' and '.ogg'.", "Unsupported file extension '{}'. Supported extensions are '.wav' and '.ogg'.",
extension extension
)); ));
} catch (...) { } catch (...) {
std::throw_with_nested( std::throw_with_nested(
runtime_error(format("Could not open sound file {}.", filePath.u8string())) runtime_error(fmt::format("Could not open sound file {}.", filePath.u8string()))
); );
} }
} }