Move extern "C" down in include/urcu/urcu-bp.h
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Aug 2022 16:49:50 +0000 (12:49 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 17 Aug 2022 17:42:24 +0000 (13:42 -0400)
A following patch adds a <type_traits> 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 <type_traits> 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<typename _Tp>
          |   ^~~~~~~~
    /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 <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/urcu/urcu-bp.h

index 2ea17e6397391fae5e081118215ac717efbc0ae0..e28c2bff8e7db3e0fda163b1655369e6799ceac4 100644 (file)
 #include <stdlib.h>
 #include <pthread.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <urcu/map/urcu-bp.h>
 
 /*
@@ -57,6 +53,10 @@ extern "C" {
  */
 #include <urcu/pointer.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef _LGPL_SOURCE
 
 #include <urcu/static/urcu-bp.h>
This page took 0.029052 seconds and 4 git commands to generate.