本文介绍了是否变量声明意味着内存分配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

会不会是precise地说,在

Will it be precise to say that in

void f() {
    int x;
    ...
}

INT X; ?是指分配的sizeof(INT)在堆栈上字节

"int x;" means allocating sizeof(int) bytes on the stack?

是否有任何的规格是什么?

Are there any specifications for that?

推荐答案

在标准规定没有什么,有一个堆栈。并没有在一个局部变量需要分配给它的内存标准的任务。变量可以被放置在寄存器中,或甚至完全除去作为优化

Nothing in the standard mandates that there is a stack. And nothing in the standard mandates that a local variable needs memory allocated for it. The variable could be placed in a register, or even removed altogether as an optimization.

这篇关于是否变量声明意味着内存分配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:38
查看更多