Remix.run Logo
dzdt 3 hours ago

For purely historical reasons the C/C++ stack is "small" with exactly how small being outside of programmer control. So you have to avoid using the stack even if it would be the better solution. Otherwise you risk your program crashing/failing with stack overflow errors.

csjh 3 hours ago | parent [-]

What do you mean outside of programmer control? What's stopping you from setting the stack size in the linker flags?

HarHarVeryFunny 3 hours ago | parent [-]

With Linux the stack size is a process limit, set with ulimit (default 8MB?). You can even set it to unlimited if you want, meaning that essentially (but not quite) the stack and heap grow towards each other only limited by the size of the address space.

ulimit only affects the main program stack though. if you are using multi-threading then there is a per-thread stack limit, which you can configure with pthreads, but not until C++23 for std::thread.