Confused about including headers

So I am using an external library and including its header, let's say <library.h>

My project has a number of helper functions in different cpp files, each one has a header that includes that <library.h>.

My main cpp file needs to use the library and the other helper functions. So its header includes all the helper headers and the <library.h>.

Is this how it's supposed to be? Or is the <library.h> actually included/compiled A LOT of times?
That is why you have header guards. It prevents inclusion more than once. So in the end only first ectountered include of particular header will work.
I have header guards on the headers for the helper functions, but still, each one includes <library.h> as it needs to use it. Not sure how to change the structure
Last edited on
If library has the proper guard too, you are fine. Else you need to hope that it does not contain anything which lead to errors wit multiple inclusions. Other than that you do not need to worry.
good point, i checked the library header and it has a #pragma once so it should be alright
Topic archived. No new replies allowed.