From 801389e72071c861c0ccf32bdca4ec5c424585b5 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 9 Dec 2021 16:07:15 -0500 Subject: [PATCH] Fix: ust-compiler: constructor/destructor build on g++ 4.8 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit g++ 4.8 build fails with: 15:16:07 ../../../../include/lttng/ust-compiler.h:104:31: error: can’t set ‘no_instrument_function’ attribute after definition 15:16:07 LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_constructor_destructor_, \ 15:16:07 ^ 15:16:07 ../../../../include/lttng/tracepoint.h:84:3: note: in definition of macro ‘LTTNG_UST___TP_COMBINE_TOKENS’ 15:16:07 _tokena##_tokenb 15:16:07 ^ 15:16:07 ../../../../include/lttng/ust-compiler.h:104:2: note: in expansion of macro ‘LTTNG_UST__TP_COMBINE_TOKENS’ 15:16:07 LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_constructor_destructor_, \ 15:16:07 ^ 15:16:07 ../../../../include/lttng/ust-tracepoint-event.h:1230:1: note: in expansion of macro ‘LTTNG_UST_DECLARE_CONSTRUCTOR_DESTRUCTOR’ 15:16:07 LTTNG_UST_DECLARE_CONSTRUCTOR_DESTRUCTOR( 15:16:07 ^ 15:16:07 In file included from ../../../../include/lttng/tracepoint.h:25:0, 15:16:07 from ust_tests_hello.h:13, 15:16:07 from tp-cpp.cpp:8: 15:16:07 ../../../../include/lttng/ust-compiler.h:109:2: error: can’t set ‘no_instrument_function’ attribute after definition 15:16:07 ~LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_constructor_destructor_, \ 15:16:07 ^ 15:16:07 ../../../../include/lttng/ust-tracepoint-event.h:1230:1: note: in expansion of macro ‘LTTNG_UST_DECLARE_CONSTRUCTOR_DESTRUCTOR’ 15:16:07 LTTNG_UST_DECLARE_CONSTRUCTOR_DESTRUCTOR( 15:16:07 ^ Fix this by moving the implementation of the constructor and destructor outside of the class, thus applying the attribute to a forward declaration. Signed-off-by: Mathieu Desnoyers Change-Id: I9e097d50dff7a8f9bef07b04ddad38bd6877f892 --- include/lttng/ust-compiler.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/lttng/ust-compiler.h b/include/lttng/ust-compiler.h index 6ce2b652..51491a5f 100644 --- a/include/lttng/ust-compiler.h +++ b/include/lttng/ust-compiler.h @@ -106,17 +106,17 @@ namespace details { \ class LTTNG_UST_COMPILER_COMBINE_TOKENS(lttng_ust_constructor_destructor_, \ name) { \ public: \ - LTTNG_UST_COMPILER_COMBINE_TOKENS(lttng_ust_constructor_destructor_, \ - name)() __VA_ARGS__ \ - { \ - constructor_func(); \ - } \ - ~LTTNG_UST_COMPILER_COMBINE_TOKENS(lttng_ust_constructor_destructor_, \ - name)() __VA_ARGS__ \ - { \ - destructor_func(); \ - } \ + LTTNG_UST_COMPILER_COMBINE_TOKENS(lttng_ust_constructor_destructor_, name)() __VA_ARGS__; \ + ~LTTNG_UST_COMPILER_COMBINE_TOKENS(lttng_ust_constructor_destructor_, name)() __VA_ARGS__; \ }; \ +LTTNG_UST_COMPILER_COMBINE_TOKENS(lttng_ust_constructor_destructor_, name)::LTTNG_UST_COMPILER_COMBINE_TOKENS(lttng_ust_constructor_destructor_, name)() \ +{ \ + constructor_func(); \ +} \ +LTTNG_UST_COMPILER_COMBINE_TOKENS(lttng_ust_constructor_destructor_, name)::~LTTNG_UST_COMPILER_COMBINE_TOKENS(lttng_ust_constructor_destructor_, name)() \ +{ \ + destructor_func(); \ +} \ } \ } \ } \ -- 2.34.1