Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use shared library in C++98 #65

Closed
jbeich opened this issue Nov 12, 2018 · 10 comments
Closed

Cannot use shared library in C++98 #65

jbeich opened this issue Nov 12, 2018 · 10 comments

Comments

@jbeich
Copy link

jbeich commented Nov 12, 2018

After boostorg/function#25 building a C++ < 11 consumer fails. Affects at least gearmand, pdfedit, uhd. CC @Kojoley

$ cat >a.cc
#include <boost/program_options.hpp>

int main(int argc, char **argv) {
  boost::program_options::options_description desc("foo");
  boost::program_options::parse_command_line(argc, argv, desc);
  return 0;
}

$ c++ -std=gnu++98 a.cc -lboost_program_options
>>> referenced by a.cc
>>>               /tmp/a-fa8c69.o:(boost::program_options::basic_command_line_parser<char>::extra_parser(boost::function1<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>))
c++: error: linker command failed with exit code 1 (use -v to see invocation)
@Kojoley
Copy link

Kojoley commented Nov 12, 2018

It is not a surprise I mentioned the roots of the problem in boostorg/function#25 (comment).

@Kojoley
Copy link

Kojoley commented Nov 12, 2018

Can you try to revert #25 locally and check with the latest boost::parameter? It looks like the actual problem is not even #25 change, but boostorg/parameter@fb88905 (boost::parameter now uses std::function when it is available).

@jbeich
Copy link
Author

jbeich commented Nov 12, 2018

boostorg/parameter@fb88905a9903 is missing on master branch, so nothing to revert. I'm testing the upcoming Boost 1.69.

@jbeich
Copy link
Author

jbeich commented Nov 12, 2018

Reverting boostorg/function#25 does help. It was the first thing I've tried.

@Kojoley
Copy link

Kojoley commented Nov 12, 2018

Can you please check if Kojoley@99727ac solves the problem?

@jbeich
Copy link
Author

jbeich commented Nov 12, 2018

After 99727ac Boost itself fails to build:

In file included from libs/program_options/src/options_description.cpp:13:
./boost/program_options/parsers.hpp:172:38: error: too few template arguments for class template 'pair'
                       function<std::pair<std::string(std::string)>,
                                     ^
./boost/container/detail/std_fwd.hpp:39:8: note: template is declared here
struct pair;
       ^
In file included from libs/program_options/src/options_description.cpp:13:
./boost/program_options/parsers.hpp:173:54: error: no viable conversion from 'boost::program_options::ext_parser' (aka 'function<pair<basic_string<char, char_traits<char>, allocator<char> >, basic_string<char, char_traits<char>, allocator<char> > > (const basic_string<char, char_traits<char>, allocator<char> > &)>') to 'int'
                                 const std::string&> ext
                                                     ^
./boost/function/function_template.hpp:955:5: note: candidate function
    operator safe_bool () const
    ^
./boost/program_options/parsers.hpp:173:54: note: passing argument to parameter 'ext' here
                                 const std::string&> ext
                                                     ^
2 errors generated.

@vprus
Copy link
Collaborator

vprus commented Nov 13, 2018

Replacing function1 with function does not seem an appropriate fix for me. Sure, it might fix program_options, however it suggests that existing code using functionN will break, which I find rather undesirable, and IIUC it's not the behaviour that @pdimov wanted either.

@Kojoley
Copy link

Kojoley commented Nov 13, 2018

it suggests that existing code using functionN will break

I do not understand why functionN still is not deprecated and used in boost libraries. There is no compilers on regression matrix that does not support partial template specialization. It is a straightforward fix to existing code to migrate to function and it only needed for the user who still uses functionN.

On the other hand, the problem is that @jbeich uses libraries compiled with C++11 with C++03 apps. I do not think we should bother about this case anymore.

@jbeich
Copy link
Author

jbeich commented Nov 13, 2018

@Kojoley, after fixing a typo in 99727ac C++98 example and the affected consumers (gearmand, pdfedit, uhd) build fine. Testing all Boost consumers for regressions downstream (~400 packages) may take more time.

@pdimov
Copy link
Member

pdimov commented Nov 13, 2018

It's probably best to revert the Function change for now.

@vprus vprus closed this as completed Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants