-2

For example: In my.h file, I included nest1.h

#ifndef MY_H
#define MY_H

#include nest1.h
...
some_function_declaration
...
#endif

And in nest1.h, I included another h file nest2.h

#ifndef NEST1_H 
#define NEST1_H

#include nest2.h
...
#endif

nest2.h

#ifndef NEST2_H
#define NEST2_H

int foo();
#endif

Will preprocessor copy foo() into my.h? Can I use foo() in my.cc file? And if nest2.h included nest3.h, can my.cc use the functions in nest3.h? And why? Please also link the relative articles if someone know the answer. Thank you!

  • some compiler have an option to see the result after the pre processing, it is -E for g++ – bruno Jan 07 '19 at 18:09

1 Answers1

0

Yes, includes work transitively.

You can include, recursively, [almost] as many headers as you want.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055