mirror of
https://github.com/nlohmann/json.git
synced 2025-08-06 07:02:42 +03:00
Fix C4702 warning and extend MSVC CI job (#4749)
* ⚗️ try matrix for latest Signed-off-by: Niels Lohmann <mail@nlohmann.me> * ♻️ refactor from https://github.com/nlohmann/json/issues/4745#issuecomment-2810128420 Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 simplify CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 simplify CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 🚨 fix cpplint warning Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 simplify CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
95
.github/workflows/windows.yml
vendored
95
.github/workflows/windows.yml
vendored
@@ -37,69 +37,48 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
run: cd build ; ctest -j 10 -C Debug --output-on-failure
|
run: cd build ; ctest -j 10 -C Debug --output-on-failure
|
||||||
|
|
||||||
msvc2019:
|
msvc:
|
||||||
runs-on: windows-2019
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
runs_on: [windows-2019, windows-2022]
|
||||||
build_type: [Debug, Release]
|
build_type: [Debug, Release]
|
||||||
architecture: [Win32, x64]
|
architecture: [Win32, x64]
|
||||||
|
std_version: [default, latest]
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.runs_on }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
- name: Run CMake
|
- name: Set generator
|
||||||
run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX"
|
id: generator
|
||||||
if: matrix.build_type == 'Release'
|
run: |
|
||||||
- name: Run CMake
|
if [ "${{ matrix.runs_on }}" = "windows-2019" ]; then
|
||||||
run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX"
|
echo "generator=Visual Studio 16 2019" >> $GITHUB_ENV
|
||||||
if: matrix.build_type == 'Debug'
|
else
|
||||||
- name: Build
|
echo "generator=Visual Studio 17 2022" >> $GITHUB_ENV
|
||||||
run: cmake --build build --config ${{ matrix.build_type }} --parallel 10
|
fi
|
||||||
- name: Test
|
shell: bash
|
||||||
run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure
|
- name: Set extra CXX_FLAGS for latest std_version
|
||||||
|
id: cxxflags
|
||||||
msvc2019_latest:
|
run: |
|
||||||
runs-on: windows-2019
|
if [ "${{ matrix.std_version }}" = "latest" ]; then
|
||||||
|
echo "flags=/permissive- /std:c++latest /utf-8 /W4 /WX" >> $GITHUB_ENV
|
||||||
steps:
|
else
|
||||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
echo "flags=/W4 /WX" >> $GITHUB_ENV
|
||||||
- name: Run CMake
|
fi
|
||||||
run: cmake -S . -B build -G "Visual Studio 16 2019" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX"
|
shell: bash
|
||||||
- name: Build
|
- name: Run CMake (Release)
|
||||||
run: cmake --build build --config Release --parallel 10
|
run: cmake -S . -B build -G "$env:generator" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="$env:flags"
|
||||||
- name: Test
|
if: matrix.build_type == 'Release'
|
||||||
run: cd build ; ctest -j 10 -C Release --output-on-failure
|
shell: pwsh
|
||||||
|
- name: Run CMake (Debug)
|
||||||
msvc2022:
|
run: cmake -S . -B build -G "$env:generator" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="$env:flags"
|
||||||
runs-on: windows-2022
|
if: matrix.build_type == 'Debug'
|
||||||
strategy:
|
shell: pwsh
|
||||||
matrix:
|
- name: Build
|
||||||
build_type: [Debug, Release]
|
run: cmake --build build --config ${{ matrix.build_type }} --parallel 10
|
||||||
architecture: [Win32, x64]
|
- name: Test
|
||||||
|
run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX"
|
|
||||||
if: matrix.build_type == 'Release'
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX"
|
|
||||||
if: matrix.build_type == 'Debug'
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --config ${{ matrix.build_type }} --parallel 10
|
|
||||||
- name: Test
|
|
||||||
run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure
|
|
||||||
|
|
||||||
msvc2022_latest:
|
|
||||||
runs-on: windows-2022
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX"
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --config Release --parallel 10
|
|
||||||
- name: Test
|
|
||||||
run: cd build ; ctest -j 10 -C Release --output-on-failure
|
|
||||||
|
|
||||||
clang:
|
clang:
|
||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
@@ -118,7 +97,7 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
||||||
|
|
||||||
clang-cl-11:
|
clang-cl-12:
|
||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
@@ -2826,17 +2826,22 @@ class binary_reader
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if constexpr(std::is_integral_v<NumberType>)
|
else if constexpr(std::is_integral_v<NumberType>)
|
||||||
{
|
{
|
||||||
number = std::byteswap(number);
|
number = std::byteswap(number);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
else
|
||||||
auto* ptr = reinterpret_cast<std::uint8_t*>(&number);
|
|
||||||
for (std::size_t i = 0; i < sz / 2; ++i)
|
|
||||||
{
|
{
|
||||||
std::swap(ptr[i], ptr[sz - i - 1]);
|
#endif
|
||||||
|
auto* ptr = reinterpret_cast<std::uint8_t*>(&number);
|
||||||
|
for (std::size_t i = 0; i < sz / 2; ++i)
|
||||||
|
{
|
||||||
|
std::swap(ptr[i], ptr[sz - i - 1]);
|
||||||
|
}
|
||||||
|
#ifdef __cpp_lib_byteswap
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -12601,17 +12601,22 @@ class binary_reader
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if constexpr(std::is_integral_v<NumberType>)
|
else if constexpr(std::is_integral_v<NumberType>)
|
||||||
{
|
{
|
||||||
number = std::byteswap(number);
|
number = std::byteswap(number);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
else
|
||||||
auto* ptr = reinterpret_cast<std::uint8_t*>(&number);
|
|
||||||
for (std::size_t i = 0; i < sz / 2; ++i)
|
|
||||||
{
|
{
|
||||||
std::swap(ptr[i], ptr[sz - i - 1]);
|
#endif
|
||||||
|
auto* ptr = reinterpret_cast<std::uint8_t*>(&number);
|
||||||
|
for (std::size_t i = 0; i < sz / 2; ++i)
|
||||||
|
{
|
||||||
|
std::swap(ptr[i], ptr[sz - i - 1]);
|
||||||
|
}
|
||||||
|
#ifdef __cpp_lib_byteswap
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user