在这里是静态的缓冲区分配呢? [英] where are static buffers allocated?

查看:158
本文介绍了在这里是静态的缓冲区分配呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说我有一个包含文件test.c的:

lets say I have a file test.c that contains:

char buffer1[1024];

int somefunction()
{
      char buffer2[1024];
      // do stuff
}

现在我知道是缓冲器2属于somefunction调用框架栈上分配的,但如果是缓冲器1分配?

now I know buffer2 is allocated on the stack on the frame belonging to somefunction calls, but where is buffer1 allocated ?

推荐答案

这些变量通常是在 BSS (变量不具有源$ C ​​$ C显式初始化,使他们获得默认值为0)或数据段(初始化DATAS)。在这里,缓冲器1 是uinitialized,所以它可能会在BSS段,它开始在数据段的终点进行分配。

These variables are typically on BSS (variables which don't have explicit initialization in the source code, so they get the value 0 by default) or data segment (initialized datas). Here, buffer1 is uinitialized, so it will probably be allocated on BSS segment, which starts at the end of the data segment.

通过 bravegnu 网站:

这篇关于在这里是静态的缓冲区分配呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆