robotology / blocktest

Test system for generic robot middlewares
GNU Lesser General Public License v3.0
8 stars 2 forks source link

Library not compiling with Boost 1.76 #47

Closed traversaro closed 3 years ago

traversaro commented 3 years ago

Apparently Boost 1.76 contains a breaking change (https://www.boost.org/users/history/version_1_76_0.html):

BREAKING CHANGE: boost::dll::import was renamed to boost::dll::import_symbol to avoid collision with C++20 import keyword.

Due to this, blocktest fails with the following error when compiled against Boost 1.76 :

../src/blocktestcore/libraryLoader.cpp: In member function 'bool BlockTestCore::LibraryLoader::load(const string&, const string&)':
../src/blocktestcore/libraryLoader.cpp:79:65: error: 'import' is not a member of 'boost::dll'
   79 |             boost::function<funcptr> stopFunction = boost::dll::import<funcptr>(
      |                                                                 ^~~~~~
../src/blocktestcore/libraryLoader.cpp:79:79: error: expected primary-expression before '>' token
   79 |             boost::function<funcptr> stopFunction = boost::dll::import<funcptr>(
      |                                                                               ^
../src/blocktestcore/libraryLoader.cpp:80:17: warning: left operand of comma operator has no effect [-Wunused-value]
   80 |                 libraryPath,
      |                 ^~~~~~~~~~~
../src/blocktestcore/libraryLoader.cpp:82:40: warning: right operand of comma operator has no effect [-Wunused-value]
   82 |                 boost::dll::load_mode::rtld_lazy
      |                                        ^~~~~~~~~
../src/blocktestcore/libraryLoader.cpp:85:72: error: 'import' is not a member of 'boost::dll'
   85 |             boost::function<funcptr1> configureFunction =  boost::dll::import<funcptr1>(
      |                                                                        ^~~~~~
../src/blocktestcore/libraryLoader.cpp:85:87: error: expected primary-expression before '>' token
   85 |             boost::function<funcptr1> configureFunction =  boost::dll::import<funcptr1>(
traversaro commented 3 years ago

Given that only two lines of code use that function, probably this can be solved via a #ifdef check on BOOST_VERSION, see https://stackoverflow.com/questions/47388867/how-to-selectively-include-boost-headers-depending-on-boost-version .

traversaro commented 3 years ago

fyi @Nicogene @triccyx

triccyx commented 3 years ago

I will check asap!

traversaro commented 3 years ago

I will check asap!

No hurry, it is probably not urgent, thanks!

triccyx commented 3 years ago

Apparently Boost 1.76 contains a breaking change (https://www.boost.org/users/history/version_1_76_0.html):

BREAKING CHANGE: boost::dll::import was renamed to boost::dll::import_symbol to avoid collision with C++20 import keyword.

Due to this, blocktest fails with the following error when compiled against Boost 1.76 :

../src/blocktestcore/libraryLoader.cpp: In member function 'bool BlockTestCore::LibraryLoader::load(const string&, const string&)':
../src/blocktestcore/libraryLoader.cpp:79:65: error: 'import' is not a member of 'boost::dll'
   79 |             boost::function<funcptr> stopFunction = boost::dll::import<funcptr>(
      |                                                                 ^~~~~~
../src/blocktestcore/libraryLoader.cpp:79:79: error: expected primary-expression before '>' token
   79 |             boost::function<funcptr> stopFunction = boost::dll::import<funcptr>(
      |                                                                               ^
../src/blocktestcore/libraryLoader.cpp:80:17: warning: left operand of comma operator has no effect [-Wunused-value]
   80 |                 libraryPath,
      |                 ^~~~~~~~~~~
../src/blocktestcore/libraryLoader.cpp:82:40: warning: right operand of comma operator has no effect [-Wunused-value]
   82 |                 boost::dll::load_mode::rtld_lazy
      |                                        ^~~~~~~~~
../src/blocktestcore/libraryLoader.cpp:85:72: error: 'import' is not a member of 'boost::dll'
   85 |             boost::function<funcptr1> configureFunction =  boost::dll::import<funcptr1>(
      |                                                                        ^~~~~~
../src/blocktestcore/libraryLoader.cpp:85:87: error: expected primary-expression before '>' token
   85 |             boost::function<funcptr1> configureFunction =  boost::dll::import<funcptr1>(

... so I wonder why we use namespace!

traversaro commented 3 years ago

I think the tricky aspect is that import in C++20 is a keyword, so not matter in which namespace it is defined, it is problematic to use it.

triccyx commented 3 years ago

@Nicogene :rocket: