Include a header in another header file

前端 未结 5 1783
别跟我提以往
别跟我提以往 2020-12-31 08:43

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

5条回答
  •  心在旅途
    2020-12-31 09:11

    Sorry, there is no way in C that you can access a definition of a structure, in another header file without including that file (through an #include). Instructions for the #include follow.

    So, lets say that the header file that contains the definition of the item structure is called "item.h", and the header file that contains the definition of the tPCB structure in "tPCB.h". At the top of tPCB.h, you should put the following statement:

    #include "item.h"
    

    This should give the tPCB.h file access to all the definitions in item.h.

提交回复
热议问题