包括另一头文件头 [英] Include a header in another header file
问题描述
我在.h文件中定义的结构项目
。现在,我定义另一个结构TPCB
在另一个.H是同一个项目的一部分,我需要的 TPCB
有一个项目
。我以为只是让同一TURBOC项目的一部分,让我在其他头文件中使用项目,但编译器会引发我未定义类型:ITE
。
I've defined a struct item
in a .h file. Now I'm defining another struct tPCB
in another .h which is part of the same project, and I need the tPCB
to have an item
. I thought that just making part of the same TurboC project would allow me to use item in the other header file, but the compiler throws me "undefined type: ite
".
我想我无论如何都必须包括关于第二个第一头,但是我已经看到了同样类似code这不这样做的工作。
I guess I somehow have to include the first header on the second one, However I have seen the same a similar code which works without doing so.
是否有任何其他方式不仅仅是增加一个的#include
线,使其工作?
Is there any other way than just adding an #include
line to make it work?
推荐答案
如果您的.c 的#include
■在正确的顺序两个.h文件,它会工作。这可能是在你记得的情况下发生了什么。最安全的做法是的#include
所有定义了你的依赖,并依赖于包括守卫在每个的.h让事情被多重定义。文件
If your .c #include
s the two .h files in the proper order, it will work. That's probably what happened in the case you remember. The safest course is to #include
every file that defines your dependencies, and rely on the include guards in each .h to keep things from being multiply defined.
这篇关于包括另一头文件头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!