0

I have started working on a project that incorporates some of boost libraries(thread and MPI). I am going to use boost multi_index in one of the modules which is not using boost at all.FYI this project has not used boost multi index before)

as soon as I tried to include

boost/multi_index_container.hpp

to the file and built the projects, I received a number of errors starting with the following:

Building CXX object CMakeFiles/SimMobility.dir/main.cpp.o
/usr/bin/c++    -fmessage-length=0 -DBOOST_NO_HASH -O0 -g -I/usr/include/postgresql -I/usr/include/soci -I/usr/include/soci/postgresql -I/usr/include/xsd -I/home/vahid/workspace/Basic__Multi_index    -o CMakeFiles/SimMobility.dir/main.cpp.o -c /home/vahid/workspace/Basic__Multi_index/main.cpp
In file included from /usr/include/boost/multi_index/detail/node_type.hpp:22:0,
                 from /usr/include/boost/multi_index/detail/index_base.hpp:21,
                 from /usr/include/boost/multi_index/detail/base_type.hpp:21,
                 from /usr/include/boost/multi_index_container.hpp:33,
                 from /home/vahid/workspace/Basic__Multi_index/geospatial/RoadNetwork.hpp:10,
                 from /home/vahid/workspace/Basic__Multi_index/main.cpp:25:
/usr/include/boost/multi_index/detail/header_holder.hpp:41:16: error: expected unqualified-id before ‘)’ token
/usr/include/boost/multi_index/detail/header_holder.hpp: In constructor ‘boost::multi_index::detail::header_holder<NodeTypePtr, Final>::header_holder()’:
/usr/include/boost/multi_index/detail/header_holder.hpp:35:32: error: expected primary-expression before ‘)’ token

may I know what the problem is? is it cmake not finding what it needs? any idea how to solve it?

Edit: in case you want to have a look at the source code, here is a simplified version:

RoadNetwork.hpp:

#pragma once

#include <iostream>
#include <vector>
#include <set>

#include <boost/multi_index_container.hpp> //causing problem!!!!!!!

namespace geo {class Links_pimpl;}
namespace sim_mob
{

//Forward declarations
class Node;
class UniNode;
class MultiNode;
class Point2D;
class Link;


namespace aimsun
{
//Forward declaration
class Loader;
}



//typedef multi_index_container<
//sim_mob::Link,
//    indexed_by<
//      random_access<>,
////            ordered_unique< member<sim_mob::Link, std::string, &sim_mob::Link::linkID> >
//    >
//> Link_m;

class RoadNetwork {
public:
    RoadNetwork() { drivingSide=DRIVES_ON_LEFT; } //TEMP

    sim_mob::Node* locateNode(const sim_mob::Point2D& position, bool includeUniNodes=false, int maxDistCM=100) const;
private:
    std::vector<sim_mob::MultiNode*> nodes;
    std::vector<sim_mob::Link*> links;

    std::vector<sim_mob::MultiNode*>& getNodesRW() { return nodes; }
    std::set<sim_mob::UniNode*>& getUniNodesRW() { return segmentnodes; }
    std::vector<sim_mob::Link*>& getLinksRW() { return links; }

friend class sim_mob::aimsun::Loader;
friend class geo::Links_pimpl;
};

}

Thank you your kind help vahid

rahman
  • 4,820
  • 16
  • 52
  • 86
  • 1
    The crystal ball is a bit cloudy, but based on my ability to see and read the source code you didn't post, it's apparent that the error is on line 42! – Jerry Coffin Apr 10 '12 at 03:22
  • @JerryCoffin sorry for this way of putting my question. I didn't have a choice. I was afraid posting source code would just add to the complexity. Did you mean line 42 of the library? (/usr/include/boost/multi_index/detail/header_holder.hpp ?) – rahman Apr 10 '12 at 05:05
  • It's kind of a joke -- 42 is "The answer to life, the universe and everything", from the Hitchhikers Guide to the Galaxy. It's my way of saying that based on what you've posted, we have absolutely no way to guess at the real problem. Narrow the problem to the smallest program that will still compile and still demonstrates the problem you're seeing, then include that in your post. – Jerry Coffin Apr 10 '12 at 05:09
  • @JerryCoffin ok :) . Hope I got you now. I just posted the code. it compiles with no problem if I just build it without the boost multi index library inclusion. – rahman Apr 10 '12 at 05:14

3 Answers3

0

I modified your header to look like this:

#pragma once

#include <iostream>
#include <vector>
#include <set>

#include <boost/multi_index_container.hpp> //causing problem!!!!!!!

using boost::multi_index_container;

namespace geo {class Links_pimpl;}
namespace sim_mob
{

//Forward declarations
class Node;
class UniNode;
class MultiNode;
class Point2D;
class Link;

namespace aimsun
{
//Forward declaration
class Loader;
}

//typedef multi_index_container<
//sim_mob::Link,
//    indexed_by<
//      random_access<>,
//            ordered_unique< member<sim_mob::Link, std::string, &sim_mob::Link::linkID> >
//    >
//> Link_m;

class RoadNetwork {
    int drivingSide;
    enum side { DRIVES_ON_LEFT, DRIVES_ON_RIGHT};
public:
    RoadNetwork() { drivingSide=DRIVES_ON_LEFT; } //TEMP

    sim_mob::Node* locateNode(const sim_mob::Point2D& position, bool includeUniNodes=false, int maxDistCM=100) const;
private:
    std::vector<sim_mob::MultiNode*> nodes;
    std::vector<sim_mob::Link*> links;
    std::set<sim_mob::UniNode*> segmentnodes;

    std::vector<sim_mob::MultiNode*>& getNodesRW() { return nodes; }
    std::set<sim_mob::UniNode*>& getUniNodesRW() { return segmentnodes; }
    std::vector<sim_mob::Link*>& getLinksRW() { return links; }

friend class sim_mob::aimsun::Loader;
friend class geo::Links_pimpl;
};

}

Then I included it in a small file that instantiated a RoadNetwork object:

#include <iostream>
#include "roadnetwork.hpp"

int main() {
    sim_mob::RoadNetwork roads;
    return 0;
}

This compiled, linked, and executed (though produced no output).

Not entirely sure what problem you're encountering...

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
  • Oh thanks. I am not in the office now.I will make the changes and will let you know the result first thing in the morning. – rahman Apr 10 '12 at 11:34
  • Hi I am back. Yes it compiled through the ordinary command line. As I mentioned, it is cmake that is susceptible to causing the problem. Any solution to that? – rahman Apr 12 '12 at 08:37
  • 1
    @rahman: Given that I can't duplicate the problem, no, I don't have much in the way of solutions. – Jerry Coffin Apr 12 '12 at 13:27
0

I encountered the same problem and tracked it down. Do you have by chance a #define final somewhere in your sources before including boost/multi_index.hpp or a -Dfinal in your compiler settings? In my case that was the problem, I use the C++11 keywords final and override in my classes and had to define them when using older compilers.

Or, maybe it's some other identifier used by multi_index that you have defined somewhere. You could dump all your defined macros as described here and check if disabling one of them helps.

Community
  • 1
  • 1
marton78
  • 3,899
  • 2
  • 27
  • 38
0

I also encountered similar problem.

I got compile error in

multi_index header_holder file.

warning : final key word is blah... blah...

So I changed the

#include <boost/xxxxx> 

position to other place. ( ex: stdafx.h etc ... ) Try this one.

gun9
  • 71
  • 1
  • 4