注意函数内部定义变量
int g_x, g_y; 和 extern g_x, g_y是完全不一样的,前面是局部变量,后面是已经定义好的外部全局变量,这里是引用外部全局变量。
#include "stdio.h"
#include "stdlib.h"
#include "utils.h"
#include "gnu/libc-version.h"
void main_test(void)
{
printf("TEST ENTRY\n");
printf("GNU libc version: %s\n", gnu_get_libc_version());
/* int g_x, g_y;*/
extern int g_x, g_y;
printf("g_x=%d, g_y=%d\n", g_x, g_y);
}
int g_x = 0;
int g_y = 1;
void test(void)
{
printf("test, g_x=%d, g_y=%d\n", g_x, g_y);
}
参考链接:
extern关键字,C语言extern关键字用法详解
http://c.biancheng.net/view/404.html