From 9aa411a7888e8d0fcc0d78f44f22f175af8fdacc Mon Sep 17 00:00:00 2001
From: Guilhem Saurel <guilhem.saurel@laas.fr>
Date: Tue, 25 May 2021 15:08:31 +0200
Subject: [PATCH] break circular include (#237)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* include registration: add failing unit test

* include registration: break circular include loop

otherwise, when a user include directly this header without fwd.hpp, as
in the include.cpp regression test:

Dans le fichier inclus depuis ../include/eigenpy/fwd.hpp:35,
                 depuis ../include/eigenpy/registration.hpp:9,
                 depuis ../unittest/include.cpp:7:
../include/eigenpy/expose.hpp: Dans la fonction « void eigenpy::expose() »:
../include/eigenpy/expose.hpp:27:9: erreur: « register_symbolic_link_to_registered_type » n'a pas été déclaré dans cette portée
   27 |     if(!register_symbolic_link_to_registered_type<T>())
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/eigenpy/expose.hpp:27:52: erreur: expected primary-expression before « > » token
   27 |     if(!register_symbolic_link_to_registered_type<T>())
      |                                                    ^
../include/eigenpy/expose.hpp:27:50: attention: le non logique est toujours appliqué au membre de gauche de la comparaison [-Wlogical-not-parentheses]
   27 |     if(!register_symbolic_link_to_registered_type<T>())
      |                                                  ^
../include/eigenpy/expose.hpp:27:54: erreur: expected primary-expression before « ) » token
   27 |     if(!register_symbolic_link_to_registered_type<T>())
      |                                                      ^
---
 include/eigenpy/registration.hpp | 4 ++--
 unittest/CMakeLists.txt          | 1 +
 unittest/include.cpp             | 9 +++++++++
 3 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 unittest/include.cpp

diff --git a/include/eigenpy/registration.hpp b/include/eigenpy/registration.hpp
index 5f44583..e001033 100644
--- a/include/eigenpy/registration.hpp
+++ b/include/eigenpy/registration.hpp
@@ -3,11 +3,11 @@
  * Copyright 2018-2019, INRIA
  */
 
+#include "eigenpy/fwd.hpp"
+
 #ifndef __eigenpy_registration_hpp__
 #define __eigenpy_registration_hpp__
 
-#include "eigenpy/fwd.hpp"
-
 namespace eigenpy
 {
   ///
diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt
index 8b2160d..ba18c9c 100644
--- a/unittest/CMakeLists.txt
+++ b/unittest/CMakeLists.txt
@@ -29,6 +29,7 @@ ADD_LIB_UNIT_TEST(matrix)
 ADD_LIB_UNIT_TEST(geometry)
 ADD_LIB_UNIT_TEST(complex)
 ADD_LIB_UNIT_TEST(return_by_ref)
+ADD_LIB_UNIT_TEST(include)
 IF(NOT ${EIGEN3_VERSION} VERSION_LESS "3.2.0")
   ADD_LIB_UNIT_TEST(eigen_ref)
 ENDIF()
diff --git a/unittest/include.cpp b/unittest/include.cpp
new file mode 100644
index 0000000..2c9f9ba
--- /dev/null
+++ b/unittest/include.cpp
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2021, CNRS
+ */
+
+// Including this header should not raise a build error
+
+#include "eigenpy/registration.hpp"
+
+BOOST_PYTHON_MODULE(include) {}
-- 
GitLab