Ask Your Question
0

Including entire services directory

asked 2019-08-01 09:54:21 -0500

mikepark93 gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-08-01 10:15:04 -0500

alsora gravatar image

updated 2019-08-01 10:23:06 -0500

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-08-01 09:54:21 -0500

Seen: 9 times

Last updated: Aug 01