From: Simon Marchi Date: Wed, 17 Aug 2022 16:49:50 +0000 (-0400) Subject: Move extern "C" down in include/urcu/urcu-bp.h X-Git-Tag: v0.12.4~6 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bf178c7f5ab7ef4cc0d6dca6195af387281d44af;p=userspace-rcu.git Move extern "C" down in include/urcu/urcu-bp.h A following patch adds a include in urcu/compiler.h. However, compiler.h gets included by urcu/pointer.h, which gets included by urcu/urcu-bp.h inside an extern "C" scope. Including the C++ header file inside an extern "C" scope doesn't work: In file included from /home/simark/src/urcu/include/urcu/compiler.h:25, from /home/simark/src/urcu/include/urcu/pointer.h:29, from /home/simark/src/urcu/include/urcu/urcu-bp.h:58, from /home/simark/src/urcu/include/urcu-bp.h:2, from /home/simark/src/urcu/tests/unit/test_urcu_multiflavor-bp.c:28, from /home/simark/src/urcu/tests/unit/test_urcu_multiflavor-bp_cxx.cpp:3: /usr/include/c++/12.1.1/type_traits:44:3: error: template with C linkage 44 | template | ^~~~~~~~ /home/simark/src/urcu/include/urcu/urcu-bp.h:41:1: note: ‘extern "C"’ linkage started here 41 | extern "C" { | ^~~~~~~~~~ Move the extern "C" in urcu-bp.h down, so that the includes are not inside it. Each header file is responsible to use extern "C" where relevant, and we should avoid including files inside such a scope. Change-Id: I42bdfa6ab445e8c40f5bcac1c1ae0786d443626c Signed-off-by: Simon Marchi Signed-off-by: Mathieu Desnoyers --- diff --git a/include/urcu/urcu-bp.h b/include/urcu/urcu-bp.h index 2ea17e6..e28c2bf 100644 --- a/include/urcu/urcu-bp.h +++ b/include/urcu/urcu-bp.h @@ -37,10 +37,6 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif - #include /* @@ -57,6 +53,10 @@ extern "C" { */ #include +#ifdef __cplusplus +extern "C" { +#endif + #ifdef _LGPL_SOURCE #include