在 Windows (GCC) 上增加堆栈大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/156510/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Increase Stack Size on Windows (GCC)
提问by Landon
Is there a way to increase the stack size of a Windows application at compile/link time with GCC?
有没有办法在编译/链接时使用 GCC 增加 Windows 应用程序的堆栈大小?
采纳答案by leppie
You could run editbin after linking.
您可以在链接后运行 editbin。
回答by Jonas Gulle
IIRC, In GCC you can provide the --stack,[bytes] parameter to ld.
IIRC,在 GCC 中,您可以向 ld 提供 --stack,[bytes] 参数。
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.
要拥有 16MiB 的堆栈,我认为默认大小是 8MiB。
回答by MSalters
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.
Windows 中有两种堆栈大小。最初提交的大小和总保留大小。您可以使用 .def 文件中的 STACKSIZE 语句设置两者。
回答by Fire Lancer
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.
创建线程时,您使用 dwStackSize 参数,但我不确定如何更改主线程的大小,这表明它在 exe 的标头中,因此它可能是编译器/链接器的一个选项,否则您需要找到标题的相关部分并自行更改。
http://msdn.microsoft.com/en-us/library/ms686774(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms686774(VS.85).aspx