void test(){
static int a=1;
int b=10;
a++;
b++;
}
int main(){
test();
test();
}
gcc -S filename.c
可以看到a不在寄存器或者栈上,存在一个单独section中。
c语言函数内局部static变量对应汇编
最新推荐文章于 2025-04-24 13:38:09 发布
void test(){
static int a=1;
int b=10;
a++;
b++;
}
int main(){
test();
test();
}
gcc -S filename.c
可以看到a不在寄存器或者栈上,存在一个单独section中。