本人想根据教程的内容本人写一个相对全面点的链表,好好练习练习,大致状况是如下这样,本人把结构和相关的一些基础函数都放在了这里,然后宏这里这样写的:
/*Data Structure: data_struct.h*/
#ifndef __DATA_STRUCT_H__
#define __DATA_STRUCT_H__
#include
#include
#include
#endif
typedef struct student{...
之后本人想单独测试每一个函数能否运行正确,所以单写一个头文件测试:
/*So called unit test: test.h*/
#ifndef __TEST_H__
#define __TEST_H__
#include "data_struct.h"
#endif
int T_struct(){...
然后本人在main里面这样写之后报错:redefination of “struct student…”
#include "data_struct.h"
#include "test.h"
int main()
{
T_struct();
return 0;
}
本人的理解是原因是的确读取data_struct.h的时候还未声明__DATA_STRUCT_H__,等到读test.h的时候__TEST_H__也没有声明……所以就又把data_struct.h给读了一遍造成了重复定义一切……
那么本人该怎么回避这种问题呢?