这里有些奇怪的问题。
[在一个.c文件中定义了一个结构,而在.h文件中定义了另一个结构,如何通过另一个.h或.h让.h文件知道.c中的结构(反之亦然)。 C。文件IE:无法编辑要包含或重新定义的文件。
main.c:
typedef struct mystruct
{
int whatever;
} Thing;
#include "header.h"
#include "otherHeaderThatIcanEdit.h"
otherstruct thisMethod()
{
//returns an otherstruct
}
header.h:
typedef struct otherstruct
{
float whatever;
} Stuff;
mystruct thisMethod()
{
//returns a mystruct;
}
在示例中,您提供了两个结构都可以被两个函数实际使用的两个函数看到。但是您应该将mystruct和otherstruct关键字放在struct之前,如下所示:
在示例中,您提供了两个结构都可以被两个函数实际使用的两个函数看到。但是您应该在mystruct和otherstruct之前加上关键字struct。