我有他们的头文件附带的这两个结构。
我的结构编号 1 是:
头文件'list.h':
typedef struct list * List;
源文件“list.c”:
struct list {
unsigned length;
char * value;
};
我的结构号 2 是:
头文件“bal.h”:
typedef enum {START, END, MIDDLE, COMMENTS, CONDITIONS} TypeListBal;
typedef struct bal * Bal;
源文件“bal.c”:
i've include those header files :
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "list.h"
struct bal {
TypeListBal type;
List name; // Name of the bal
List attributes[]; // Array of type struct List
};
当我尝试在我的 bal.c 文件中使用一个函数时,例如:
Bal createBal(List name){
char * search;
const char toFind = '=';
search = strchr(name->value, toFind);
}
我在这一行遇到错误:search = strchr(name->value, toFind);
说:错误:取消引用指向不完整类型的指针
我不知道为什么因为我已经在我的 bal.c 中包含了 list.h
我在 Stackoverflow 上读过很多书,说这种类型的程序被称为:不透明类型,这似乎非常好,但我不知道如何将我的其他头文件用于其他源文件。我认为我所要做的就是将我的 list.h 包含在我的 bal.c 文件中。
我正在用这个 commamd 在 gcc 中编译:gcc -g -W -Wall -c bal.c bal.h
非常感谢你 !