在我的C程序分解后,我遇到了访问结构的问题。这是代码
storage.h定义
#ifndef STORAGE_H
#define STORAGE_H
#include "list.h"
#define MAX_TITLE_SIZE 1000
typedef struct Finances {
int revenue;
} Finances;
typedef struct Website
{
char title[MAX_TITLE_SIZE];
int visitors;
float average;
Finances revenue;
} Website;
List * Strage_readFile(const char * fileName);
#endif
storage.c
#include "storage.h"
void blankfunc();
list.h
#ifndef LIST_H
#define LIST_H
#include "storage.h"
typedef struct List {
struct List * next;
} List;
#endif
list.c
#include "list.h"
void blankfunc();
我收到此错误
storage.h:22:1: error: unknown type name ‘List’
List * Strage_readFile(const char * fileName);
^~~~
那么,我如何组织这两个标题之间的连接,以便可以在任一标题中访问网站和列表结构?
答案 0 :(得分:2)
相互包容是你的问题。 storage.h
必须包含list.h
进行编译,list.h
包含storage.h
出于某种原因。
只需从storage.h
list.h
的冗余包含即可