作为一个简单的初学者项目,我正在尝试构建一个链表。我为节点创建了一个结构 typedef。我的问题是我想要另一个 typedef 作为指向列表节点的指针,出于某种原因,这不起作用,我很困惑。我在这里阅读了其他答案,但没有一个有效。
主文件
#include <stdio.h>
#include "linkedList.h"
int main(int argc, char **argv){
return 0;
}
Run Code Online (Sandbox Code Playgroud)
链表.h
#ifndef linkedList
#define linkedList
typedef struct listStrNode {
char *string;
struct listStrNode *next;
} listStringNode;
typedef listStringNode *linkedList;
#endif
Run Code Online (Sandbox Code Playgroud)
错误
In file included from main.c:3:
linkedList.h:9:35: error: expected identifier or ‘(’ before ‘;’ token
9 | typedef listStringNode *linkedList;
|
Run Code Online (Sandbox Code Playgroud)
编译:
gcc main.c
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?