mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-19 13:18:32 +00:00
xrt: Add XRT_STRUCT_INIT define
This helps with code that needs to be compiled with both C and C++.
This commit is contained in:
parent
8c0735feec
commit
f0021c359f
|
@ -146,3 +146,31 @@ typedef intptr_t ssize_t;
|
||||||
* @ingroup xrt_iface
|
* @ingroup xrt_iface
|
||||||
*/
|
*/
|
||||||
#define container_of(ptr, type, field) (type *)((char *)ptr - offsetof(type, field))
|
#define container_of(ptr, type, field) (type *)((char *)ptr - offsetof(type, field))
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XRT_DOXYGEN
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Very small default init for structs that works in both C and C++. Helps with
|
||||||
|
* code that needs to be compiled with both C and C++.
|
||||||
|
*
|
||||||
|
* @ingroup xrt_iface
|
||||||
|
*/
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
#define XRT_STRUCT_INIT {}
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
#elif defined(__cplusplus)
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
#define XRT_STRUCT_INIT {}
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
#define XRT_STRUCT_INIT {0}
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue