Ask Your Question

Revision history [back]

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.

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"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.