首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

调试时出现有关问题,帮小弟我看看吧

2012-03-07 
调试时出现问题,帮我看看吧我有一个wordcount.c,一个wordpool.c,wordpool.hC/C++ code //wordpool.h里面的

调试时出现问题,帮我看看吧
我有一个wordcount.c,一个wordpool.c,wordpool.h

C/C++ code
 //wordpool.h里面的声明 int find (const char *wp);  void add (const char *wp);  void print ();


C/C++ code
//wordpool.c里面的函数#include "wordpool.h"int find (const char *wp); void add (const char *wp); void print ();


C/C++ code
//wordcount.c里面的函数,我在main里面调用了add和print//文件里include了wordTable.h,wordTable.c#include "wordTable.h"#include "wordTable.c"int main (int argc, char *argv[]){}int read ();{}


如果我同时include了wordpool.h,wordpool.c,测试不能运行,说我add和print函数多重定义了
如果我在wordcount.c里不include那个wordpool.c,build的时候就会说未定义的reference到函数add和print.
这倒底是什么问题啊?
我把代码上传到网盘了
http://rapidshare.com/files/380807924/test.rar.html

[解决办法]
#include "wordTable.c"
没有这样用的,include的只有头文件,你在worldTable.h声明函数,在worldTable定义函数就可以了,不需要自阿声明,在需要使用这些函数的文件里,include这个头文件就可以
[解决办法]
.c文件是不允许被包含的,否则在编译时,wordTable.c自己被编译一遍,在wordcount.c里又被编译一次,所有在wordtable.c里定义的函数、全局变量都必然导致符号重定义错误

热点排行