There are certain conditions that can cause stack overflows on an x86 Linux system:
struct my_big_object[HUGE_NUMBER]
on the stack. Walking throu
There isn't a nice way I can think of. Maybe it is possible by using getrlimit() (suggested before) and some pointer arithmetic? But first ask yourself if you really want this.
void *closeToBase; main () { int closeToBase; stackTop = &closeToBase; } int stackHasRoomFor(int bytes) { int currentTop; return getrlimit(...) - (¤tTop - closeToBase) > bytes + SomeExtra; }
Personally, I'd not do this. Allocate big things on the heap, the stack was not meant for it.