有多大是有一定程序的堆栈存储器,并且有可以设置任何编译器标志? [英] How big is the stack memory for a certain program, and are there any compiler flags that can set it?

查看:168
本文介绍了有多大是有一定程序的堆栈存储器,并且有可以设置任何编译器标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为标题指出:有没有对堆栈的大小任何一般的经验法则。我猜大小将根据操作系统的不同而不同,体系结构,高速缓存(S)的大小,多少可用的RAM等。

As the title states: Is there any general "rule of thumb" about the size of the stack. I'm guessing the size will vary depending on the OS, the architecture, the size of the cache(s), how much RAM is available etc.

不过可以在任何一般的说,或者是还有什么办法找出如何栈多,的这个的程序被允许使用?作为奖励的问题是有没有办法(与编译器标志等。(想主要是C / C ++在这里,但也比较一般))堆栈的大小可以由用户设置为一个固定的大小?

However can anything be said in general, or is there any way to find out, how much of the stack, this program is allowed to use?. As a bonus question is there any way (with compiler flags etc. (thinking mostly C/C++ here, but also more general)) that the size of the stack can be set to a fixed size by the user?

顺便说一句,我问严格出于好奇,我没有一个堆栈溢出。 :)

Btw, I'm asking strictly out of curiosity, I'm not having a stack overflow. :)

推荐答案

是的,你可以设置堆栈大小,它通常是一个连接标志,它取决于你的工具链(通常这是由编译器的名字被称为)。

Yes you can set the stack size, it usually is a linker flag, and it depends on your toolchain (typically this is referred to by the name of the compiler).

  • For Microsoft Visual C++, use the /F option to change the size, and DUMPBIN /HEADERS to see what the setting is.
  • For the GCC toolchain and most other Unix linkers, use -Wl,--stack

您还可以在这里找到在计算器上一些现有的问题。

You will also find several existing questions here on StackOverflow.

这篇关于有多大是有一定程序的堆栈存储器,并且有可以设置任何编译器标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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