How to use C++ linked list in Ros node??
to use the linked list in a Cpp code we use include<list> .. but it doesn't work for a ROS node,SO how can I use it in a ROS node??!!
I assume that the problem that cmakelists should has something to declare the C++ standard libraries my catkin_make output:
/home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp: In constructor ‘Graph::Graph(int)’:
/home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp:25:12: error: expected type-specifier before ‘list’
adj = new list<int>[V];
^
/home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp:25:12: error: expected ‘;’ before ‘list’
/home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp:26:9: error: expected primary-expression before ‘int’
tree = int[V][V];
^
/home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp:26:9: error: expected ‘;’ before ‘int’
/home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp: In member function ‘void Graph::GridToGraph(int, int)’:
/home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp:54:6: error: ‘g’ was not declared in this scope
g.addEdge(grid[k][j], grid[k + 1][j]);
^
/home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp:61:5: error: ‘g’ was not declared in this scope
g.addEdge(grid[k][j], grid[k][j + 1]);
^
/home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp:66:5: error: ‘g’ was not declared in this scope
g.addEdge(grid[k][j], grid[k][j + 1]);
^
/home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp: In member function ‘void Graph::prim_st()’:
/home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp:95:5: error: ‘list’ was not declared in this scope
list<int>::iterator i;
^
/home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp:95:5: note: suggested alternatives:
In file included from /usr/include/c++/4.8/list:63:0,
from /opt/ros/indigo/include/ros/forwards.h:35,
from /opt/ros/indigo/include/ros/common.h:37,
from /opt/ros/indigo/include/ros/ros.h:43,
from /home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp:4:
/usr/include/c++/4.8/bits/stl_list.h:438:11: note: ‘std::list’
class list : protected _List_base<_Tp, _Alloc>
^
In file included from /usr/include/boost/mpl/aux_/include_preprocessed.hpp:37:0,
from /usr/include/boost/mpl/list.hpp:46,
from /usr/include/boost/math/policies/policy.hpp:9,
from /usr/include/boost/math/policies/error_handling.hpp:19,
from /usr/include/boost/math/special_functions/round.hpp:14,
from /opt/ros/indigo/include/ros/time.h:58,
from /opt/ros/indigo/include/ros/ros.h:38,
from /home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp:4:
/usr/include/boost/mpl/aux_/preprocessed/gcc/list.hpp:22:8: note: ‘boost::mpl::list’
struct list;
^
In file included from /usr/include/boost/lexical_cast.hpp:170:0,
from /opt/ros/indigo/include/ros/transport_hints.h:34,
from /opt/ros/indigo/include/ros/subscribe_options.h:33,
from /opt/ros/indigo/include/ros/node_handle.h:41,
from /opt/ros/indigo/include/ros/ros.h:45,
from /home/ubuntu/catkin_ws/src/moon/src/SpanningTree.cpp:4:
/usr/include/boost/container/container_fwd ...
There is nothing special about ROS, and
#include <list>
should just work. Please include whatever error messages or output you see when trying to do that, and please include how you are setting things up and then building your nodes.I edit my question adding the errors :)