使用标题中其他文件中的结构

问题描述 投票:0回答:1

我已经在文件a.h中定义了一个结构(称之为测试),该结构应被许多文件使用。在文件b.h中,我需要使用此结构,但不能将其用作指针(struct test a[32]而不是struct test* a)作为另一个结构的属性之一(请称之为test_container)。但我收到了error: array type has incomplete element type。我猜是因为编译器不知道测试结构,所以它无法确定test_container需要多少空间。所以我想在b.h中添加#include <a.h>,但是随后我收到了fatal error: a.h: No such file or directory。这两个文件都在同一目录中。有什么问题?

c struct include
1个回答
1
投票

使用#include "a.h"包括您自己的.h

通过这种方式,您应该发布真实代码而不是描述。

© www.soinside.com 2019 - 2024. All rights reserved.