2011-06-28 133 views
0

可以說我有一個包含b.hxx和c.hxx的頭文件a.hxx。頭文件包含Quesiton

現在,如果我在d.cxx文件中包含這個a.hxx文件,b.hxx和c.hxx會自動(隱式地)包含在內嗎?

P.S:這不是一個家庭作業問題。我很想知道這件事。

回答

0

是的。 當您使用d.hxx文件有a.hxx b.hxx的所有內容,並c.hxx

0

是,整個事情被視爲字符的一個大的數據流:

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