c - 头文件 c 中“record_t”之前的预期声明说明符或“...”
问题描述
我是 C 中这个头文件的新手。
我想要做的是使用 makefile 一起编译我的代码文件。每个头文件有 2 个头文件和 2 个 c 文件,还有 1 个 main.c 文件。
我有 main.c 这是我的主要功能,它有“#include”dict2.h“”。dict1 和 dict2 标头有些相同。不同的是 dict2 有额外的链表功能。
-bash-4.1$ make dict1
gcc -Wall -c main.c -o main.o -g
In file included from main.c:6:
dict2.h:1: warning: useless storage class specifier in empty declaration
dict2.h:8: warning: useless storage class specifier in empty declaration
dict2.h:21: error: expected declaration specifiers or '...' before 'record_t'
dict2.h:24: error: expected declaration specifiers or '...' before 'record_t'
dict2.h:42: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
dict2.h:45: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
dict2.h:48: error: expected ')' before '*' token
make: *** [main.o] Error 1
我的 dict2.h 函数看起来像这样:
typedef struct record_t;
typedef struct node_list node_list_t;
struct node_list;
typedef struct list_t;
typedef struct node node_t;
struct node;
node_t* transform_input(FILE *finput, node_t *root);
//line 21
node_t* bst_insert(node_t *root, record_t* data);
//line 24
node_t* bst_create_node(node_t* root, record_t* data);
node_t* bst_search(node_t* root, char* name_keyword, int* numcomparison);
void search_then_print(char* keyword, node_t* root, FILE* foutput, \
int* numcomparison);
void freeTree(node_t *root);
void print_record(FILE* foutput, node_t* targetnode, char* keyword,\
int* numcomparison);
//line 42
list_t *insert_at_foot(list_t *list, record_t *datarecord);
//line 45
list_t *create_empty_list(void);
//line 48
void free_list(list_t* list);
我查看了在线讨论,但试图修复它,但我在头文件中找不到错误。
谢谢您的帮助。
解决方案
声明:
typedef struct record_t;
typedef struct list_t;
错过类型名称。
应该是:
typedef struct record record_t;
typedef struct list list_t;
推荐阅读
- php - 使特定 URL 使用模板文件并使用 PHP 和 .htaccess 从数组中获取特定数据
- python - 我的重新加载功能出现 pylance 错误?
- javascript - 如何将输入值数据从 Vue 组件传递到根元素
- javascript - 无法对齐包装器中的项目
- firebase - 我们可以在flutter中使用流将数据分配给类变量(而不是将数据映射到小部件)
- django - 从 Google Cloud Platform 的 Secret Manager 读取 django_settings 不起作用
- python - Tweepy user_timeline 占据 1 个位置,但 2 个位置出现错误
- julia - 如何在 Julia 中输入 x̂ 或 ŷ?
- python - 使用请求抓取 javascript 数据返回 404
- javascript - 如何从 API 向动态变化的对象添加属性?