1

I am installing rnnlib through https://github.com/meierue/RNNLIB

After installing the boost and other and completing other steps I am getting the error- SeqBuffer.hpp:227: error: reference to ‘range’ is ambiguous Helpers.hpp:298: error: candidates are: template<class T> std::pair<boost::iterators::counting_iterator<Incrementable, boost::iterators::use_default, boost::iterators::use_default>, boost::iterators::counting_iterator<Incrementable, boost::iterators::use_default, boost::iterators::use_default> > range(const T&, const T&)

Makefile:223: recipe for target 'DataExporter.o' failed
make[2]: *** [DataExporter.o] Error 1
make[2]: Leaving directory '/home/adminhp/Himaanshu/RNNLIB-master/src'
Makefile:217: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/adminhp/Himaanshu/RNNLIB-master'
Makefile:155: recipe for target 'all' failed
make: *** [all] Error 2
user459
  • 111
  • 8

1 Answers1

2

using namespace strikes again.

Helpers.hpp contains the following damning sequence:

using namespace std;
using namespace boost;
using namespace boost::assign;
using namespace boost::posix_time;
using namespace boost::gregorian;

Frankly, at this point I'd give up. Especially the first two lines are the moral equivalent of carpet bombing. With napalm.¹

UPDATE Created a pull request with the changes required to make the code compile.

To further compound the problem, RNNLIB's range facility is not even in a namespace...

So, the upshot is that range collides with the namespace from boost.

The simplest way to remove the clash is to qualify all the loopy uses of range as ::range...

PS. same comes up with equal later on


¹ Why is "using namespace std" considered bad practice?

Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633
  • 1
    I've created a pull request that solves the compilation problems: https://github.com/meierue/RNNLIB/pull/2 – sehe Dec 17 '15 at 09:30
  • I have made the changes you mentioned. But after that I am getting this error. Helpers.hpp: In function ‘std::pair::type, boost::use_default, boost::use_default>, boost::counting_iterator::type, boost::use_default, boost::use_default> > indices(const R&)’: Helpers.hpp:301: error: expected primary-expression before ‘(’ token – user459 Dec 17 '15 at 11:39
  • 1
    So you didn't apply all the changes :) – sehe Dec 17 '15 at 11:50
  • You mean I should also make the changes for "equal" also..? – user459 Dec 17 '15 at 12:08
  • 1
    Nope. All the changes. Including the ones in Helpers.cpp. And the reorderings. And the qualifications. You know, just the 4 commits in the pull request. I really don't know how to make it clearer than a pull request. – sehe Dec 17 '15 at 12:09
  • Okie Yes. Thanks a lot. It worked :). Now I am getting some errors related to make file. Makefile:223: recipe for target 'Main.o' failed make[2]: *** [Main.o] Error 1 make[2]: Leaving directory '/home/adminhp/Himaanshu/RNNLIB-master/src' Makefile:217: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/adminhp/Himaanshu/RNNLIB-master' Makefile:155: recipe for target 'all' failed make: *** [all] Error 2 Thanks for your help. – user459 Dec 17 '15 at 12:22
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/98229/discussion-between-himaanshu-gauba-and-sehe). – user459 Dec 17 '15 at 12:23