main.c
#include "test.h"
#include <stdio.h>
int main(int argc, const char * argv[])
{
// static 修饰的函数: 是一个内部函数(只能在定义的那个文件中去使用)
// int a = sum(2, 3);
int a = function(2, 3);
printf("%d\n", a);
// extern声明的函数, 可以在定义文件中使用, 也可以在其他文件中使用.
extern void temp();
temp();
return 0;
}
test.h
#ifndef test_h
#define test_h
#include <stdio.h>
// static 修饰的函数: 是一个内部函数(只能在定义的那个文件中去使用)
// static int sum(int a, int b);
int function(int a,int b);
//extern void temp();
#endif /* test_h */
test.c
#include "test.h"
// extern void temp();
static int sum(int a, int b)
{
return a + b;
}
int function(int a, int b)
{
return sum(a, b);
}
// 函数声明的同时 , 定义函数 // 可以省略extern
extern void temp()
{
printf("im a function extern int temp()\n");
}