Search code examples
c++xcodeheader-filesinclusion

Mutual Inclusion of Header Files


Let's say I have a header file called inclusions.h that has all the #include <...>s for my project. inclusions.h includes another header file called settings.h, where various constants can be modified.

If #include <math.h> in inclusions.h, will settings.h have access to the math library as well? Or do I have to #include <math.h> in settings.h as well?


Solution

  • If math.h is included before settings.h, settings.h should also have access to math.h. But to ensure the access (and to indicate the dependencies), you should include the files where they are needed, so also in math.h.