当编译期间分配的内存? [英] When is memory allocated during compilation?

查看:122
本文介绍了当编译期间分配的内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我写

int main()
{
    int j;
}

有J的存储器被编译期间在编译的时间分配,但是当?当存储器被分配给一个变​​量有哪些不同编译阶段?如果结果表明:J全球性的?

The memory for 'j' is allotted at the time of compilation,but when during compilation ? What are the various stages of compilation when memory is allotted to a variable? What if j was global ?

推荐答案

我猜你是混合的东西了。

I guess you are mixing things up.

编译器不变量分配内存 - 它产生code,它在运行时为变量分配内存。对于全局的将被添加到程序启动code。

Compiler doesn't allocate memory for variables - it generates code that allocates memory for variables at runtime. For globals is will be added to program start-up code.

这篇关于当编译期间分配的内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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