From 22e61b41079e5e15123b5fccc5557a0495c6138f Mon Sep 17 00:00:00 2001 From: sgvandijk Date: Thu, 3 Jan 2019 19:54:08 +0000 Subject: [PATCH] Ensure that context instance id storage is aligned correctly (#365) * Ensure that context instance id storage is aligned correctly * Make alignment compatible with MSVC * Namespace alignment macro with RCL_ --- rcl/include/rcl/context.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rcl/include/rcl/context.h b/rcl/include/rcl/context.h index 71bae07..64610e0 100644 --- a/rcl/include/rcl/context.h +++ b/rcl/include/rcl/context.h @@ -29,6 +29,13 @@ extern "C" #include "rcl/types.h" #include "rcl/visibility_control.h" +#ifdef _MSC_VER +#define RCL_ALIGNAS(N) __declspec(align(N)) +#else +#include +#define RCL_ALIGNAS(N) alignas(N) +#endif + typedef uint64_t rcl_context_instance_id_t; struct rcl_context_impl_t; @@ -132,7 +139,7 @@ typedef struct rcl_context_t * See this paper for an effort to make this possible in the future: * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0943r1.html */ - uint8_t instance_id_storage[RCL_CONTEXT_ATOMIC_INSTANCE_ID_STORAGE_SIZE]; + RCL_ALIGNAS(8) uint8_t instance_id_storage[RCL_CONTEXT_ATOMIC_INSTANCE_ID_STORAGE_SIZE]; } rcl_context_t; /// Return a zero initialization context object.