diff --git a/src/xrt/state_trackers/oxr/oxr_objects.h b/src/xrt/state_trackers/oxr/oxr_objects.h index c22056f53..090923d56 100644 --- a/src/xrt/state_trackers/oxr/oxr_objects.h +++ b/src/xrt/state_trackers/oxr/oxr_objects.h @@ -44,6 +44,18 @@ extern "C" { #define XRT_CAST_PTR_TO_OXR_HANDLE(HANDLE_TYPE, PTR) \ ((HANDLE_TYPE)(uint64_t)(uintptr_t)(PTR)) +/*! + * @brief Cast an OpenXR handle to a pointer in such a way as to avoid warnings. + * + * Avoids -Wint-to-pointer-cast by first casting to a 64-bit int, then to a + * pointer-sized int, then to the desired pointer type. That's a lot of no-ops + * on 64-bit, but a narrowing (!) conversion on 32-bit. + * + * @ingroup oxr + */ +#define XRT_CAST_OXR_HANDLE_TO_PTR(PTR_TYPE, HANDLE) \ + ((PTR_TYPE)(uintptr_t)(uint64_t)(HANDLE)) + /*! * @defgroup oxr_main OpenXR main code *