开发者

Header file inclusion

开发者 https://www.devze.com 2023-03-15 16:28 出处:网络
Lets say that I have a header file a.hxx which includes b.hxx and c.hxx. Now if I cinlude this a.hxx file in the d.cxx file, does b.hxx and c.hxx automatically (implicitly) get included?

Lets say that I have a header file a.hxx which includes b.hxx and c.hxx.

Now if I cinlude this a.hxx file in the d.cxx file, does b.hxx and c.hxx automatically (implicitly) get included?

P.S: This is not a homework question. I was cur开发者_开发技巧ious to know about this.


Yes it does. When you use d.hxx file it has all the contents of a.hxx b.hxx and c.hxx


Yes, the whole thing gets treated as one big stream of characters:

pax$ cat a.hxx
#warning START A
#include "b.hxx"
#include "c.hxx"
#warning END.. A
//==============

pax$ cat b.hxx
#warning START B
#warning END.. B
//==============

pax$ cat c.hxx
#warning START C
#warning END.. C
//==============

pax$ cat d.cxx
#warning START D
#include "a.hxx"
#warning END.. D
//==============

 

pax$ gcc -c -o d.o d.cxx
d.cxx:1:2: warning: #warning START D
In file included from d.cxx:2:
a.hxx:1:2: warning: #warning START A
In file included from a.hxx:2,
                 from d.cxx:2:
b.hxx:1:2: warning: #warning START B
b.hxx:2:2: warning: #warning END.. B
In file included from a.hxx:3,
                 from d.cxx:2:
c.hxx:1:2: warning: #warning START C
c.hxx:2:2: warning: #warning END.. C
In file included from d.cxx:2:
a.hxx:4:2: warning: #warning END.. A
d.cxx:3:2: warning: #warning END.. D
0

精彩评论

暂无评论...
验证码 换一张
取 消