How big is the stack memory for a certain program, and are there any compiler flags that can set it?
c, c++, memory, size, stack
Solution
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.
Problem
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. 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. :)