0
$\begingroup$

Rosanswers logo

I have a srv directory that has all the services I have created. In my main node I am including each individual .hpp manually. Is there a way to include all the .hpp files in one include statement, or do I need to do it for each individual service I created?


Originally posted by mikepark93 on ROS Answers with karma: 47 on 2019-08-01

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

No, C++ does not allow that.

However, you may create a file named my_services.hpp with all the includes.

#pragma once

#include "srv_pkg/srv/service_1"
#include "srv_pkg/srv/service_2"
#include "srv_pkg/srv/service_3"
#include "srv_pkg/srv/service_4"

Then in all the places where you need to use the services you can just use #include "my_services.hpp".

An alternative would be to use a script to automatically add all the include directives to your files, but I really think that's a bad and error-prone solution.


Originally posted by alsora with karma: 1322 on 2019-08-01

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.