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

条件编译的有关问题

2012-02-07 
条件编译的问题//test.c#includetest.h //main.c#includetest.h intmain(){return0}//test.h#ifndeft

条件编译的问题
//test.c

#include   "test.h "


//main.c

#include   "test.h "

int   main(){
                return   0;
}


//test.h

#ifndef   test_h
#define   test_h

int   a;

#endif

问题是为什么编译时还会出现重复定义的错误?
我的用法上有什么错误吗?


[解决办法]
"两个 C文件是先各自编译成 obj 文件,再 link 在一起的。 "

#ifdef等这些东西,在词法分析前就处理完了,叫预处理。

所以link的时候,会出现重复定义。

热点排行