Skip to content
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

MSVC C++20 Support #126

Merged
merged 20 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions .github/matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,52 @@
"compiler": "gcc",
"version": "11",
"os": "ubuntu-22.04",
"cxxstd" : "17"
"cxxstd": "17"
},
{
"name": "Linux GCC 11 C++20",
"compiler": "gcc",
"version": "11",
"os": "ubuntu-22.04",
"cxxstd" : "20"
"cxxstd": "20"
},
{
"name": "Linux Clang 14 C++17",
"compiler": "clang",
"version": "14",
"os": "ubuntu-22.04",
"cxxstd" : "17"
"cxxstd": "17"
},
{
"name": "Linux Clang 14 C++20",
"compiler": "clang",
"version": "14",
"os": "ubuntu-22.04",
"cxxstd" : "20"
"cxxstd": "20"
},
{
"name": "macOS apple-clang 14.3.1",
"name": "macOS apple-clang 14.3.1 C++17",
"compiler": "apple-clang",
"version": "14.3.1",
"os": "macos-13",
"cxxstd" : "17"
"cxxstd": "17"
},
{
"name": "Windows VS2022",
"name": "macOS apple-clang 14.3.1 C++20",
"compiler": "apple-clang",
"version": "14.3.1",
"os": "macos-13",
"cxxstd": "20"
},
{
"name": "Windows VS2022 C++17",
"os": "windows-2022",
"cxxstd": "17"
},
{
"name": "Windows VS2022 C++20",
"os": "windows-2022",
"cxxstd" : "17"
"cxxstd": "20"
}
]
}
4 changes: 2 additions & 2 deletions .github/workflows/adobe_source_libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ jobs:
shell: bash
run: |
mkdir ../build
cmake -S. -B../build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17
cmake -S. -B../build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=${{matrix.config.cxxstd}}

- name: Configure (Windows)
if: ${{ startsWith(matrix.config.os, 'windows') }}
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
mkdir ..\build
cmake -S. -B../build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DBOOST_TEST_DYN_LINK=TRUE
cmake -S. -B../build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=${{matrix.config.cxxstd}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DBOOST_TEST_DYN_LINK=TRUE

- name: Build (Unix)
if: ${{ startsWith(matrix.config.os, 'ubuntu') || startsWith(matrix.config.os, 'macos') }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ gh-pages/

documentation/doxyfile.bak
build_asl/
.vs/
20 changes: 0 additions & 20 deletions .vscode/c_cpp_properties.json

This file was deleted.

136 changes: 0 additions & 136 deletions .vscode/settings.json

This file was deleted.

5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.29)
include(FindGit)
include(CMakeParseArguments)
enable_testing()
Expand All @@ -7,8 +7,7 @@ project(adobe_source_libraries CXX)

set(CMAKE_CXX_EXTENSIONS OFF)
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++17")
set(CMAKE_CXX_STANDARD 20)
endif(NOT DEFINED CMAKE_CXX_STANDARD)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to assume that dropping the Xcode setting is intentional and correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It isn't needed.


set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
Expand Down
19 changes: 13 additions & 6 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@
"configurePresets": [
{
"name": "debug",
"displayName": "Custom configure preset",
"displayName": "debug-windows",
"description": "Sets Ninja generator, build and install directory",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_STANDARD": "20",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"VCPKG_TARGET_TRIPLET": "x64-windows"
},
"architecture": {
"value": "x64",
"strategy": "external"
},
"toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [ "Windows" ]
"hostOS": [
"Windows"
]
}
}
},
Expand All @@ -36,7 +39,9 @@
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [ "macOS" ]
"hostOS": [
"macOS"
]
}
}
},
Expand All @@ -53,14 +58,16 @@
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [ "macOS" ]
"hostOS": [
"macOS"
]
}
}
}
],
"buildPresets": [
{
"name": "debug",
"name": "debug-windows",
"description": "",
"displayName": "",
"configurePreset": "debug"
Expand Down
31 changes: 31 additions & 0 deletions adobe/exception.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2013 Adobe
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
/**************************************************************************************************/

#ifndef ADOBE_EXCEPTION_HPP
#define ADOBE_EXCEPTION_HPP

#include <string>

/**************************************************************************************************/

namespace adobe {

/**************************************************************************************************/

/// invoke `std::terminate` with the given message.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? You can't invoke std::terminate with a message, so you need to fix this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the comment to be more clear.

[[noreturn]] void terminate(const char*);
[[noreturn]] void terminate(const std::string&);

/**************************************************************************************************/

} // namespace adobe

/**************************************************************************************************/

#endif

/**************************************************************************************************/
4 changes: 2 additions & 2 deletions adobe/implementation/toroid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class byte_toroid_t : boost::noncopyable {

void purify(toroid_node_t* p) {
toroid_header_t* c(column_of(p));
int x(p->color_m);
auto x(p->color_m);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely not needed for C++20 support? Why is it even an improvement?

Aside: we really don't use copy-initialization anymore? This syntax makes it look like a function declaration.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This silences a warning because x is char type and later uses will narrow back to a char type.


c->color_m = x;

Expand All @@ -248,7 +248,7 @@ class byte_toroid_t : boost::noncopyable {

void unpurify(toroid_node_t* p) {
toroid_header_t* c(column_of(p));
int x(p->color_m);
auto x(p->color_m);

for (toroid_node_t* rr = up_of(c); rr != c; rr = up_of(rr)) {
if (rr->color_m < 0) {
Expand Down
4 changes: 3 additions & 1 deletion adobe/json_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#include <adobe/any_regular.hpp>
#include <adobe/array.hpp>
#include <adobe/dictionary.hpp>
#include <adobe/exception.hpp>
#include <adobe/json.hpp>
#include <adobe/macro_utilities.hpp>

/**************************************************************************************************/

Expand Down Expand Up @@ -56,7 +58,7 @@ struct asl_json_helper_t {
else if (type == typeid(adobe::empty_t))
return json_type::null;

ADOBE_ASSERT(false && "invalid type for serialization");
terminate(ADOBE_MESSAGE("invalid type for serialization"));
}

template <typename T>
Expand Down
Loading
Loading