OC static 和函数

 

#include <stdio.h>

// 定义一个one函数
// 完整地定义一个外部函数需要extern关键字
//extern void one() {
//    printf("调用了one函数\n");
//}

// 内部函数,需要用static关键字修饰,说明不能在其他文件中访问
static void one() {
    printf("调用了one函数\n");
}
#ifndef extern____one_h
#define extern____one_h

// 完整地声明一个函数,需要用到extern关键字,表示引用一个外部函数
// extern void one();

// 其实extern又是废的,所以可以省略
void one();

#endif

 

 

#include <stdio.h>

// 提前声明内部的one函数
static void one();


int main(int argc, const char * argv[])
{
    one();
    return 0;
}

// 定义了一个内部函数,这跟one.c中one函数是互不干扰
static void one() {
    
}

 

posted on 2017-05-24 16:42  守望星空  阅读(207)  评论(0编辑  收藏  举报

导航