两个文件的宏定义和变量之间的交互

1.cpp

 
#include <stdio.h>
#include<stdlib.h>
#define one123 123
extern bb;
void main()
{
int aa;
aa=1;
    aa=one123;
printf("%d\n",aa);
printf("%d",bb);
}
 
2.cpp
 
#define one123 233
int bb=one123;
 
总结:两个文件的宏定义只在本文件中有效,不干涉其它文件,而若要用到另一文件的变量必须extern 
posted @ 2013-02-24 13:15  yurius  阅读(967)  评论(0编辑  收藏  举报