Skip to content

Commit 2b3b3f4

Browse files
authored
C++17 or later use inline constexpr vars (#305)
1 parent 0474c59 commit 2b3b3f4

2 files changed

Lines changed: 83 additions & 2 deletions

File tree

.github/workflows/wslcxx.yml

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ permissions:
2929
contents: read
3030

3131
jobs:
32-
build:
32+
buildgcc:
3333
runs-on: ubuntu-latest
3434

3535
strategy:
@@ -108,3 +108,82 @@ jobs:
108108
- name: 'Build (C++20)'
109109
working-directory: ${{ github.workspace }}/Tests
110110
run: cmake --build out/build/${{ matrix.build_type }}
111+
112+
buildclang:
113+
runs-on: ubuntu-latest
114+
115+
strategy:
116+
fail-fast: false
117+
118+
matrix:
119+
build_type: [x64-Debug-Linux, x64-Release-Linux]
120+
clang: [16, 17, 18]
121+
122+
steps:
123+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
124+
125+
- name: Clone test repository
126+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
127+
with:
128+
repository: walbourn/directxmathtest
129+
path: Tests
130+
ref: main
131+
132+
- uses: seanmiddleditch/gha-setup-ninja@3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # v6
133+
134+
- name: 'Configure CMake (C++17)'
135+
working-directory: ${{ github.workspace }}/Tests
136+
run: cmake --preset=${{ matrix.build_type }}
137+
env:
138+
CC: clang-${{ matrix.clang }}
139+
CXX: clang++-${{ matrix.clang }}
140+
141+
- name: 'Build (C++17)'
142+
working-directory: ${{ github.workspace }}/Tests
143+
run: cmake --build out/build/${{ matrix.build_type }}
144+
145+
- name: 'Clean up'
146+
working-directory: ${{ github.workspace }}
147+
run: rm -rf out
148+
149+
# Test suite requires C++17 features on Linux, so we only test the headers for C++11/C++14
150+
- name: 'Configure CMake (C++11)'
151+
working-directory: ${{ github.workspace }}/Tests/headertest
152+
run: cmake --preset=${{ matrix.build_type }} -DBUILD_CXX11=ON
153+
env:
154+
CC: clang-${{ matrix.clang }}
155+
CXX: clang++-${{ matrix.clang }}
156+
157+
- name: 'Build (C++11)'
158+
working-directory: ${{ github.workspace }}/Tests/headertest
159+
run: cmake --build out/build/${{ matrix.build_type }}
160+
161+
- name: 'Clean up'
162+
working-directory: ${{ github.workspace }}/Tests/headertest
163+
run: rm -rf out
164+
165+
- name: 'Configure CMake (C++14)'
166+
working-directory: ${{ github.workspace }}/Tests/headertest
167+
run: cmake --preset=${{ matrix.build_type }} -DBUILD_CXX14=ON
168+
env:
169+
CC: clang-${{ matrix.clang }}
170+
CXX: clang++-${{ matrix.clang }}
171+
172+
- name: 'Build (C++14)'
173+
working-directory: ${{ github.workspace }}/Tests/headertest
174+
run: cmake --build out/build/${{ matrix.build_type }}
175+
176+
- name: 'Clean up'
177+
working-directory: ${{ github.workspace }}/Tests/headertest
178+
run: rm -rf out
179+
180+
- name: 'Configure CMake (C++20)'
181+
working-directory: ${{ github.workspace }}/Tests
182+
run: cmake --preset=${{ matrix.build_type }} -DBUILD_CXX20=ON
183+
env:
184+
CC: clang-${{ matrix.clang }}
185+
CXX: clang++-${{ matrix.clang }}
186+
187+
- name: 'Build (C++20)'
188+
working-directory: ${{ github.workspace }}/Tests
189+
run: cmake --build out/build/${{ matrix.build_type }}

Inc/DirectXMath.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2006,7 +2006,9 @@ namespace DirectX
20062006
// separate math routine it would be reloaded.
20072007

20082008
#ifndef XMGLOBALCONST
2009-
#if defined(__GNUC__) && !defined(__MINGW32__)
2009+
#if __cplusplus >= 201703L
2010+
#define XMGLOBALCONST inline constexpr
2011+
#elif defined(__GNUC__) && !defined(__MINGW32__)
20102012
#define XMGLOBALCONST extern const __attribute__((weak))
20112013
#else
20122014
#define XMGLOBALCONST extern const __declspec(selectany)

0 commit comments

Comments
 (0)