C 错误:未知的类型名称。找不到头文件中定义的结构

C 错误:未知的类型名称。找不到头文件中定义的结构,c,gcc,C,Gcc,我试图使用头文件中定义的结构,但gcc无法识别该结构。我已经寻找过类似的问题,但没有一个解决方案有效 这是头文件代码: #ifndef _HTTPLIB_H_ #define _HTTPLIB_H_ #include <stdio.h> typedef struct req_buffer{ char* page; int type; //1 - html, 2 - comp int socket; Req_buffer * next; time_t conn

我试图使用头文件中定义的结构,但gcc无法识别该结构。我已经寻找过类似的问题,但没有一个解决方案有效

这是头文件代码:

#ifndef _HTTPLIB_H_
#define _HTTPLIB_H_


#include <stdio.h>

typedef struct req_buffer{
  char* page;
  int type; //1 - html, 2 - comp
  int socket;
  Req_buffer * next;
  time_t conn_time,response_time;
}Req_buffer;

#endif

Req_buffer*next在声明之前,您正在引用符号
Req\u buffer
。尝试将其更改为:

struct req_buffer* next;

不能在
typedef
内部使用
Req\u buffer
,接下来必须使用
struct Req\u buffer*是的,但为什么会这样?因为当编译器在结构定义中看到
Req\u buffer
时,它没有看到
Req\u buffer
是一个类型的定义(但它知道
struct Req\u buffer
是一个类型-它已经看到了该信息)。
struct req_buffer* next;