i designed a C++ program in linux, which for not to give stack overflow uses:
-fno-stack-limit
and
-fstack-check
so it runs ok.
But I want to port it to windows, I compiled with no problem in DEV-c++ and
added this options manually to the linker, but I get stack overflow when I try
to run the program
Any ideas?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In Windows, a process is given ~2Mb stack by default. I do not know whether
there is a linker option to change that - I doubt it, since to do so would
affect other processes on the system by potentially hogging large amounts of
memory.
If your program overflows a stack that large 2Mb, I suggest that there is a
problem with it. Either a bug, or bad design, or uncontrolled recursion, so
perhaps just a large object that would be more appropriately allocated either
statically or on the heap.
I'd fix the problem rather than using kludgy head-in-the-sand fixes.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My answer should probably have been "read the manual", but it is not
always obvious which manual. In this case it is the GNU linker manual. The
option you need is (follow the link).
I still think that if you are significantly exceeding the default without good
reason (or more importantly without understanding why), then you should really
fix that in preference to this solution.
Hi,
i designed a C++ program in linux, which for not to give stack overflow uses:
-fno-stack-limit
and
-fstack-check
so it runs ok.
But I want to port it to windows, I compiled with no problem in DEV-c++ and
added this options manually to the linker, but I get stack overflow when I try
to run the program
Any ideas?
Thanks
In Windows, a process is given ~2Mb stack by default. I do not know whether
there is a linker option to change that - I doubt it, since to do so would
affect other processes on the system by potentially hogging large amounts of
memory.
If your program overflows a stack that large 2Mb, I suggest that there is a
problem with it. Either a bug, or bad design, or uncontrolled recursion, so
perhaps just a large object that would be more appropriately allocated either
statically or on the heap.
I'd fix the problem rather than using kludgy head-in-the-sand fixes.
... after further research on your behalf;
My answer should probably have been "read the manual", but it is not
always obvious which manual. In this case it is the GNU linker manual. The
option you need is (follow the link).
I still think that if you are significantly exceeding the default without good
reason (or more importantly without understanding why), then you should really
fix that in preference to this solution.
http://sourceware.org/binutils/docs-2.16/ld/Options.html#index-
_002d_002dstack-277