Increase Stack Size on Windows (GCC)

2020-01-25 10:38发布

Is there a way to increase the stack size of a Windows application at compile/link time with GCC?

4条回答
男人必须洒脱
2楼-- · 2020-01-25 11:11

There are two stack sizes in Windows. The initially commited size, and the total reserved size. You can set both with a STACKSIZE statement in a .def file.

查看更多
ゆ 、 Hurt°
3楼-- · 2020-01-25 11:12

When creating threads you use the dwStackSize paremater, but I'm not sure how to change the size for the main thread, this indicates its in the exe's header, so it may be an option for the compiler/linker, else you need to find the relevant part of the header and change it yourself.

http://msdn.microsoft.com/en-us/library/ms686774(VS.85).aspx

查看更多
放我归山
4楼-- · 2020-01-25 11:27

You could run editbin after linking.

查看更多
一纸荒年 Trace。
5楼-- · 2020-01-25 11:37

IIRC, In GCC you can provide the --stack,[bytes] parameter to ld.

E.g.

gcc -Wl,--stack,16777216 -o file.exe file.c

To have a stack of 16MiB, I think that the default size is 8MiB.

查看更多
登录 后发表回答