C++ wrapper: get rid of the Boost dependency
authorAurelien Jarno <aurelien@aurel32.net>
Tue, 13 May 2025 21:40:40 +0000 (23:40 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Tue, 10 Jun 2025 15:10:07 +0000 (17:10 +0200)
The C++ wrapper relies on boost::shared_ptr, likely due to the lack of a
standard smart pointer at the time of the C++ wrapper implementation.
However, std::shared_ptr has been available by default in GCC since
version 6.1, and even with GCC 4.7 when explicitely using the -std=c++11
option.

This commit replaces all usages of boost::shared_ptr with
std::shared_ptr, eliminating the dependency on the Boost library. Since
the smart pointer is only used in private member variables and both
types have the same size, this change does not affect the ABI.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

CMakeLists.txt
README.build
examples/CMakeLists.txt
ftdipp/CMakeLists.txt
ftdipp/ftdi.hpp

index 5494357..385952e 100644 (file)
@@ -45,7 +45,7 @@ find_package ( LibUSB REQUIRED )
 include_directories ( ${LIBUSB_INCLUDE_DIR} )
 
 # Find Boost
-if (FTDIPP OR BUILD_TESTS)
+if (BUILD_TESTS)
   find_package( Boost REQUIRED )
 endif()
 
index e130ca0..54c253f 100644 (file)
@@ -14,7 +14,7 @@ earlier, it is recommended you build libusbx-1.0.14 or later).
 
 sudo apt-get install libconfuse-dev (for ftdi-eeprom) (yum install libconfuse-devel)
 sudo apt-get install swig python-dev (for python bindings) (yum install swig python-devel)
-sudo apt-get install libboost-all-dev (for C++ binding and unit test) (yum install boost-devel)
+sudo apt-get install libboost-all-dev (for unit test) (yum install boost-devel)
 
 3) Clone the git repository
 mkdir libftdi
index 9ec7bff..bda84e0 100644 (file)
@@ -38,7 +38,6 @@ endif(NOT MINGW)
 # libftdi++ examples
 if( FTDIPP )
   include_directories(BEFORE ${PROJECT_SOURCE_DIR}/ftdipp
-    ${Boost_INCLUDE_DIRS}
   )
 
   # Target
index 360a831..71e6055 100644 (file)
@@ -8,8 +8,6 @@ include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}
   ${PROJECT_SOURCE_DIR}/src
 )
 
-include_directories(${Boost_INCLUDE_DIRS})
-
 # Shared library
 add_library(ftdipp1 SHARED ${cpp_sources})
 
@@ -20,7 +18,7 @@ set_target_properties(ftdipp1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSIO
 set_target_properties(ftdipp1 PROPERTIES CLEAN_DIRECT_OUTPUT 1)
 
 # Dependencies
-target_link_libraries(ftdipp1 ftdi1 ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES})
+target_link_libraries(ftdipp1 ftdi1 ${LIBUSB_LIBRARIES})
 
 install ( TARGETS ftdipp1
           RUNTIME DESTINATION bin
index f569cce..2458327 100644 (file)
@@ -31,7 +31,7 @@ on this file might be covered by the GNU General Public License.
 
 #include <list>
 #include <string>
-#include <boost/shared_ptr.hpp>
+#include <memory>
 #include <ftdi.h>
 
 namespace Ftdi
@@ -145,7 +145,7 @@ protected:
 
 private:
     class Private;
-    boost::shared_ptr<Private> d;
+    std::shared_ptr<Private> d;
 };
 
 /*! \brief Device EEPROM.
@@ -168,7 +168,7 @@ public:
 
 private:
     class Private;
-    boost::shared_ptr<Private> d;
+    std::shared_ptr<Private> d;
 };
 
 /*! \brief Device list.
@@ -214,7 +214,7 @@ public:
 
 private:
     class Private;
-    boost::shared_ptr<Private> d;
+    std::shared_ptr<Private> d;
 };
 
 }