Commit fe675e3
committed
Fix build with GCC < 11: [[fallthrough]] is supported but not allowed in C
I think GCC says `__has_cpp_attribute(fallthrough)` is true because C++
supports it (it means "has C++ attribute"), but that doesn't apply to
the C language. This causes a compilation error:
```
compilersupport_p.h:57:41: error: expected expression before '[' token
57 | # define CBOR_FALLTHROUGH [[fallthrough]]
| ^
cborparser.c:225:13: note: in expansion of macro 'CBOR_FALLTHROUGH'
225 | CBOR_FALLTHROUGH;
| ^~~~~~~~~~~~~~~~
```
Instead, we should use the C23 `__has_c_attribute` to detect the C
attribute.
Fixes #293.
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>1 parent 6d932c0 commit fe675e3
1 file changed
+5
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
| |||
0 commit comments