The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

xrt: adds helper macro for C11 struct compound literals

if you have C functions/exprs which use
C11 style designated-initializers for struct compound
literals and this code is using C++ this causes
warning messages (even with C++20),

the new macro helps when these are included in either C or C++

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2555>

+21
+21
src/xrt/include/xrt/xrt_compiler.h
··· 201 201 // clang-format on 202 202 203 203 #endif 204 + 205 + /* 206 + * C11 style designated initializers (as compound literals) causes warning messages 207 + * in C++ (even in C++20), usage: 208 + * 209 + * @code{.c} 210 + * static inline struct xrt_foo_bar 211 + * xrt_foo_bar_make() 212 + * { 213 + * return XRT_C11_COMPOUND(struct xrt_foo_bar){ 214 + * .x = y, 215 + * // ... 216 + * }; 217 + * } 218 + * @endcode 219 + */ 220 + #ifdef __cplusplus 221 + #define XRT_C11_COMPOUND(X) 222 + #else 223 + #define XRT_C11_COMPOUND(X) (X) 224 + #endif