常量变量存储在 C 中的什么位置? [英] Where are constant variables stored in C?

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

问题描述

我想知道常量变量存储在哪里.它和全局变量在同一个内存区域吗?还是在堆栈上?

I wonder where constant variables are stored. Is it in the same memory area as global variables? Or is it on the stack?

推荐答案

它们的存储方式是一个实现细节(取决于编译器).

How they are stored is an implementation detail (depends on the compiler).

例如,在 GCC 编译器中,在大多数机器上,只读变量、常量和跳转表都放在文本部分.

For example, in the GCC compiler, on most machines, read-only variables, constants, and jump tables are placed in the text section.

这篇关于常量变量存储在 C 中的什么位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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