其中,被存储在存储器参数变量? [英] Where are Parameter variables stored in memory?

查看:113
本文介绍了其中,被存储在存储器参数变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一些C code和跨越我想知道一种方法,其中的参数变量存储在内存中来的时候。
我知道以下内容:

I am writing some code in C and when coming across a method I wondered where parameter variables were stored in memory. I know the following:

全局变量 - >存储在静态code部分

global variables -> stored in code section of static

静态varables - >

static varables ->

局部自动变量(inside方法) - >存储在堆栈上

local auto variables (inside methods) -> stored on the stack

局部静态变量 - >保存在栈上

local static variables -> stored on the stack

地方了const变量 - >保存在栈上

local const variables -> stored on the stack

假设我的假设是正确的。

Assuming my assumptions are correct.

但如果保存参数变量?例如:为int *(INT X,字符* C);

but where are parameter variables stored? ex: int *(int x, char *c);

谢谢!

编辑:
我知道,当我malloc的东西,它被放置在堆上,但是说我取消引用指针来获得在指针位置的价值,是也存储在堆中还是现在在栈?

I know that when I malloc something, it is placed on the heap, but say I dereference the pointer to get the value at the pointer location, is that also stored in the heap or is it now in the stack?

推荐答案

这取决于许多不同的东西,调用约定是寻找到主要的事情。这 86 页转到成不同的调用约定,以及如何参数传递给函数和此引用越过调用各种C ++编译器和平台使用的约定。一般而言,要么将是通过寄存器堆栈。

It depends on many different things, the calling convention is the main thing to look into. This x86 page goes into various calling conventions and how parameters are passed to a function and this reference goes over calling conventions used by various C++ compilers and platforms. In general it is either going to be on the stack of through registers.

我的回答 C ++(嵌套)函数调用的指令 - 寄存器也是相关的,有一些有用的链接

My answer to C++ (nested) function call instructions - registers is also relevant and has some more useful links.

这篇关于其中,被存储在存储器参数变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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