因此,我在头path.h中定义了以下结构
typedef struct path Path;
struct Path {
Path* branching_paths;
uint32_t nb_paths;
};在同一个标题中,我声明并定义了以下内联函数:
inline void init_path(Path* path);
inline void init_path(Path* path){
path->branching_paths = NULL;
path->nb_paths = 0;
}我不知道我为什么会犯这个错误..。我已经搜索了网页,但据我所见,我已经在标题中正确地定义了结构,还是我遗漏了什么?
./../Path.h:54:9: error: dereferencing pointer to incomplete type 'Path {aka struct path}'
path->branching_paths = NULL;发布于 2016-08-15 18:13:26
您的typedef中有一个错误。
您为typedef定义了一个struct path,然后定义了struct Path。因为C是区分大小写的,所以它们被看作是两个独立的类型。
按照现在的方式,您声明了struct path (使用Path作为别名),但是还没有定义它。因此,当您试图取消引用一个Path *时,编译器不知道该结构是什么样子,因为您还没有告诉它。
你想要的是:
typedef struct Path Path;https://stackoverflow.com/questions/38960385
复制相似问题