extern的正确使用 test1.c和test2.c,test2中要用到test1中的全局变量temp 1、在test1.c中定义且初始化:int8_t temp = 0; 2、再在test1.h中用extern声明:extern int8_t temp;(注:这里不可以初始化,加= 0) 3、最后在test2.c中包含test1.h:#include “test1.h”