假设我有一个包含b.hxx和c.hxx的头文件a.hxx。
现在,如果我把这个a.hxx文件放在d.cxx文件中,b.hxx和c.hxx会自动(隐式地)包含进来吗?
附言:这不是一个家庭作业问题。我很好奇地想知道这件事。
发布于 2011-06-28 14:21:51
是的,确实如此。使用d.hxx文件时,它包含a.hxx b.hxx和c.hxx的所有内容
发布于 2011-06-28 14:27:15
是的,整个事情都被看作是一大串字符:
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.. Dhttps://stackoverflow.com/questions/6502361
复制相似问题