gpt4 book ai didi

c - 为什么编译器将变量存储在寄存器中?

转载 作者:行者123 更新时间:2023-12-02 07:33:06 25 4
gpt4 key购买 nike

<分区>

嗨,我一直在阅读各种文档中的此类内容

register

Tells the compiler to store the variable being declared in a CPU register.

In standard C dialects, keyword register uses the following syntax:

register data-definition;

The register type modifier tells the compiler to store the variable being declared in a CPU register (if possible), to optimize access. For example,

register int i;

Note that TIGCC will automatically store often used variables in CPU registers when the optimization is turned on, but the keyword register will force storing in registers even if the optimization is turned off. However, the request for storing data in registers may be denied, if the compiler concludes that there is not enough free registers for use at this place.

http://tigcc.ticalc.org/doc/keywords.html#register

我的观点不仅仅是注册。我的观点是为什么编译器会将变量存储在内存中。编译器的任务就是编译并生成目标文件。在运行时发生实际的内存分配。为什么编译器会做这个生意。我的意思是,如果不通过编译文件本身来运行目标文件,内存分配是否会在 C 的情况下发生?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com