Commit 0e63af9
authored
Fix the build failure with C++20 standard (apache#302)
### Motivation
When building the project with the `-DCMAKE_CXX_STANDARD=20` option and
GCC 11.3, it failed. There are two main reasons.
One is the `ObjectPool.h`, see http://eel.is/c++draft/diff.cpp17.class#2
In short, see the code below:
```c++
template <typename T>
struct A {
// A<T>() {} // error: simple-template-id not allowed for constructor
A() {} // OK, injected-class-name used
};
```
The other reason is deeply hidden and OS-specific. When building the
target for the unit test, the `lib/` directory is added into the include
directories. So for `#include "Semaphore.h"`, the `Semaphore.h` header
will be looked up first in the `lib/` directory. However, C++20
introduced a `<semaphore>` header, which finds the POSIX semaphore
header `semaphore.h` in the system path.
For example, the include order in `ubuntu:22.04` arm64 container is:
- `$PROJECT_DIR/lib/` (where `Semaphore.h` is)
- ...
- `/usr/lib/gcc/aarch64-linux-gnu/11/include` (where `semaphore.h` is)
The C++ header is case insensitive so the `lib/Semaphore.h` will be
included by the `<semaphore>` header, which is implicitly included by
`<thread>`. Our own `Semaphore.h` does not have the POSIX semaphore
struct definitions so the build failed.
### Modifications
- Fix the semantics error in `ObjectPool.h`
- Remove the `lib/` directory from the included directories of the unit
test and include `lib/xxx.h` for header in `lib/` directory.
- Add a workflow to verify now it can be built with C++201 parent e737716 commit 0e63af9
File tree
13 files changed
+45
-18
lines changed- .github/workflows
- lib
- tests
- c
13 files changed
+45
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
98 | 122 | | |
99 | 123 | | |
100 | 124 | | |
| |||
281 | 305 | | |
282 | 306 | | |
283 | 307 | | |
284 | | - | |
| 308 | + | |
285 | 309 | | |
286 | 310 | | |
287 | 311 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
227 | | - | |
| 226 | + | |
| 227 | + | |
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
| |||
53 | 52 | | |
54 | 53 | | |
55 | 54 | | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 19 | | |
24 | 20 | | |
25 | 21 | | |
| |||
31 | 27 | | |
32 | 28 | | |
33 | 29 | | |
| 30 | + | |
34 | 31 | | |
35 | 32 | | |
| 33 | + | |
| 34 | + | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
28 | 27 | | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
0 commit comments