jupyter-xeus / xeus-cling

Jupyter kernel for the C++ programming language
BSD 3-Clause "New" or "Revised" License
3.02k stars 292 forks source link

missing standard header <iterator> in xoptions.cpp #440

Closed zkoza closed 1 year ago

zkoza commented 2 years ago

This is a gcc 12.1 error report:

> g++ -c xoptions.cpp -I../Include
g++ -c xoptions.cpp -I../include
xoptions.cpp: In member function ‘cxxopts::ParseResult xcpp::xoptions::parse(const std::string&)’:
xoptions.cpp:21:52: error: ‘istream_iterator’ is not a member of ‘std’
   21 |         std::vector<std::string> opt_strings((std::istream_iterator<std::string>(iss)),
      |                                                    ^~~~~~~~~~~~~~~~
xoptions.cpp:15:1: note: ‘std::istream_iterator’ is defined in header ‘<iterator>’; did you forget to ‘#include <iterator>’?
   14 | #include "xeus-cling/xoptions.hpp"
  +++ |+#include <iterator>
   15 | 
xoptions.cpp:21:80: error: expected primary-expression before ‘>’ token
   21 | tor<std::string> opt_strings((std::istream_iterator<std::string>(iss)),
      |                                                                ^

xoptions.cpp:22:52: error: ‘istream_iterator’ is not a member of ‘std’
   22 |                                               std::istream_iterator<std::string>());
      |                                                    ^~~~~~~~~~~~~~~~
xoptions.cpp:22:52: note: ‘std::istream_iterator’ is defined in header ‘<iterator>’; did you forget to ‘#include <iterator>’?
xoptions.cpp:22:80: error: expected primary-expression before ‘>’ token
   22 |                                  std::istream_iterator<std::string>());
      |                                                                   ^

xoptions.cpp:22:82: error: expected primary-expression before ‘)’ token
   22 |                                  std::istream_iterator<std::string>());
      |                                                                     ^

Thus, adding

#include <iterator>

in xoptions.cpp should fix the problem.

I found this issue while trying to install jupyter-xeus in Manjaro Linux.

JoelSjogren commented 2 years ago

Same problem here, and adding that #include <iterator> fixed it.

If you have the same problem and it hasn't been patched yet, you can edit the source code yourself and build with makepkg -e.