English 中文(简体)
为什么地方的变式初始化指示与全球变量相比,不会促成可执行的规模?
原标题:Why don t local variable initialisation instructions contribute to the executable size as much as global variables do?
  • 时间:2024-05-06 02:45:13
  •  标签:
  • c
  • memory

我宣读的案文是:

全球变量位于可执行的形象,因此,使用全球变量数将提高可执行图像的规模。

问题:

  1. www.un.org/spanish/ecosoc 什么是可执行的形象? 从我读到的全球变数中,这些变量位于可执行的数据部分。 我认为,当地变式的初始化指示储存在案文部分。 So 所以,地方变式初始化指令没有涉及与全球变量相同的空间?

  2. 如果可以执行,这是否意味着只凭非挥发性记忆才能被击落记忆或执行? 全球变数是否还占用了更多的可执行空间,无法装入援助团?

  3. 是否有图书或简明阅读资源,我不妨提到,这将有助于我掌握如此低层次的概念?

我预计,当地变量初始化指示的大小将占用与全球变量相同的可执行空间。 考虑以下方案:

#include <stdlib.h>

int global_var = 10

int main(void){

    int local_var = 20;
    return EXIT_SUCCESS;
}

当转换成机器可执行(假定其未装入记忆/而不是过程)时,我假定对<代码>全球_var和<代码> 当地_var将编码为机级代码,尽管在可执行的不同章节(数据和案文)中。 因此,为什么<条码>全球_var会占用更多的空间?

问题回答

所有物体都记忆犹新。 如果是初步的,必须存放在某个地方。

然而,并非所有物体申报都是平等的。 举例来说,有“global_var,其中必须有一个已实现的int 物体空间,有些地方可以在你的节目中使用。 这占用了空间。

但当地<代码> 当地_var很有可能由于编辑人员的存在而得到最佳利用,因为汇编者可以证明自己从未使用过(或仅用于不需要实际储存的int的物体。

唯一必要的是初步价值,这种价值必须在方案的某些地方存在。 页: 1 要求储存其初步价值也是没有道理的。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签