lib: put __BT_UPCAST() and __BT_UPCAST_CONST() in `babeltrace.h`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 10 Jul 2019 06:15:51 +0000 (02:15 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 10 Jul 2019 15:25:15 +0000 (11:25 -0400)
This makes it possible to clear those macros at the end of
`babeltrace.h`. This is safe because each public header is guaranteed to
be included from `babeltrace.h`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib030f70869b48e76bd78a91be55e581aeb3f3435
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1676
Tested-by: jenkins <jenkins@lttng.org>
include/babeltrace2/babeltrace.h
include/babeltrace2/types.h

index 739e76b3b3a1b4ae142a995a94646df3d5cff4e3..b9ce9847ad191a8488758d26e81e4eed52538175 100644 (file)
 # define __BT_IN_BABELTRACE_H
 #endif
 
-/* Need by some of the following included headers */
+/* Internal: needed by some of the following included headers */
 #include <babeltrace2/func-status.h>
 
+/* Internal: needed by some of the following included headers */
+#ifdef __cplusplus
+# define __BT_UPCAST(_type, _p)                static_cast<_type *>(static_cast<void *>(_p))
+# define __BT_UPCAST_CONST(_type, _p)  static_cast<const _type *>(static_cast<const void *>(_p))
+#else
+# define __BT_UPCAST(_type, _p)                ((_type *) (_p))
+# define __BT_UPCAST_CONST(_type, _p)  ((const _type *) (_p))
+#endif
+
 /* Core API */
 #include <babeltrace2/current-thread.h>
 #include <babeltrace2/error-cause-const.h>
 #undef __BT_FUNC_STATUS_UNSUPPORTED
 #undef __BT_FUNC_STATUS_CANCELED
 #undef __BT_IN_BABELTRACE_H
+#undef __BT_UPCAST
+#undef __BT_UPCAST_CONST
 
 #endif /* BABELTRACE2_BABELTRACE_H */
index 9808ec1d00db21439f7b2d159442f4def5acbc92..99d9f1bfbf804f94693c563baf95afc14f3cfcf7 100644 (file)
 
 #include <stdint.h>
 
-/* Internal use */
-#ifdef __cplusplus
-# define __BT_UPCAST(_type, _p)                static_cast<_type *>(static_cast<void *>(_p))
-# define __BT_UPCAST_CONST(_type, _p)  static_cast<const _type *>(static_cast<const void *>(_p))
-#else
-# define __BT_UPCAST(_type, _p)                ((_type *) (_p))
-# define __BT_UPCAST_CONST(_type, _p)  ((const _type *) (_p))
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
This page took 0.027373 seconds and 4 git commands to generate.