
1、静态函数只能在声明它的文件中可见,其他文件不能引用该函数。
2、不同的文件可以使用相同名字的静态函数,互不影响。
3、使用static声明的函数不能被另一个文件引用。
实例
/*file1.c*/
#include<stdio.h>
staticvoidfun(void)
{
printf("hellofromfun.\n");
}
intmain(void)
{
fun();
fun1();
return0;
}
/*file2.c*/
#include<stdio.h>
staticvoidfun1(void)
{
printf("hellofromstaticfun1.\n");
}
/*
输出:
error:file1.c:(.text+0x20):对‘fun1’未定义的引用
collect2:error:ldreturned1exitstatus
*/
以上就是c语言中static修饰函数的介绍,希望对大家有所帮助。更多C语言学习指路:C语言教程
原文来自:https://www.py.cn© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
















































暂无评论内容