From 91425ccb6ff0a416b67ef21eb3ecebb49ba3e748 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 6 May 2025 19:45:03 +0800 Subject: Update C++ standard to C++20 (#6980) * Correct incorrect enum usage on metal * Update C++ standard to C++20 Closes https://github.com/shader-slang/slang/issues/6945 * use bit_cast --- cmake/CompilerFlags.cmake | 2 +- source/core/slang-io.cpp | 2 +- source/slang/slang-ir.h | 8 +------- tools/slang-test/slang-test-main.cpp | 2 +- tools/test-server/test-server-main.cpp | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake index 24a2c574f..2019b554b 100644 --- a/cmake/CompilerFlags.cmake +++ b/cmake/CompilerFlags.cmake @@ -175,7 +175,7 @@ function(set_default_compile_options target) ON # C++ standard CXX_STANDARD - 17 + 20 # pic POSITION_INDEPENDENT_CODE ON diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp index 5490294ca..851c70073 100644 --- a/source/core/slang-io.cpp +++ b/source/core/slang-io.cpp @@ -752,7 +752,7 @@ String Path::getRelativePath(String base, String path) auto result = std::filesystem::relative(p2, p1, ec); if (ec) return path; - return String(UnownedStringSlice(result.generic_u8string().c_str())); + return String(reinterpret_cast(result.generic_u8string().c_str())); } SlangResult Path::remove(const String& path) diff --git a/source/slang/slang-ir.h b/source/slang/slang-ir.h index ea784c9a6..5a1ae94f7 100644 --- a/source/slang/slang-ir.h +++ b/source/slang/slang-ir.h @@ -7,9 +7,6 @@ // similar in spirit to LLVM (but much simpler). // -#if defined(__cpp_lib_bit_cast) -#include -#endif #include "../compiler-core/slang-source-loc.h" #include "../compiler-core/slang-source-map.h" #include "../core/slang-basic.h" @@ -17,6 +14,7 @@ #include "slang-container-pool.h" #include "slang-type-system-shared.h" +#include #include namespace Slang @@ -105,11 +103,7 @@ enum IRMemoryOrder inline int32_t operator&(const IROpMask m, const IROp o) { -#if defined(__cpp_lib_bit_cast) return std::bit_cast(m) & std::bit_cast(o); -#else - return (int32_t)m & (int32_t)o; -#endif } inline int32_t operator&(const IROp o, const IROpMask m) diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index c0697b4a4..1fb70ed03 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -58,7 +58,7 @@ extern "C" extern "C" { - __declspec(dllexport) extern const char* D3D12SDKPath = u8".\\D3D12\\"; + __declspec(dllexport) extern const char* D3D12SDKPath = ".\\D3D12\\"; } #endif diff --git a/tools/test-server/test-server-main.cpp b/tools/test-server/test-server-main.cpp index 63535ec92..3faa6352f 100644 --- a/tools/test-server/test-server-main.cpp +++ b/tools/test-server/test-server-main.cpp @@ -28,7 +28,7 @@ extern "C" extern "C" { - __declspec(dllexport) extern const char* D3D12SDKPath = u8".\\D3D12\\"; + __declspec(dllexport) extern const char* D3D12SDKPath = ".\\D3D12\\"; } #endif -- cgit v1.2.3