Clion中C程序的堆栈大小增加 [英] Increasing stack size for C program in Clion
问题描述
如何为具有深度递归调用的C程序增加堆栈的最大大小?项目是否有任何配置,可以指定可执行文件的堆栈或堆大小?
How can one increase the maximum size of a stack for C program that has a deep recursive call? Is there any config for the project where one can specify the stack or heap size for executables?
推荐答案
要在OP自身上扩展答案,以下三个CMake命令在Windows上都对我有用,MinGW / GCC(将< target>
替换为您在 add_executable()中输入的内容)
):
To expand on the OP's own answer, the following three CMake commands all work for me on Windows with MinGW/GCC (replace <target>
with what you entered into add_executable()
):
target_link_libraries(<target> PRIVATE "-Wl,--stack,10000000")
OR
set_target_properties(<target> PROPERTIES LINK_FLAGS -Wl,--stack,10000000)
OR
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,10000000")
根据 CMake文档,每个文档都应仅添加链接器标志,而不是替换任何已设置的标志。
According to the CMake documentation, each of these should just add linker flags, not replace any that are already set.
在Visual中Studio,您应根据/ STACK:替换 -Wl,-stack href = https://gitlab.kitware.com/cmake/cmake/issues/17572 rel = nofollow noreferrer>此线程
及其他。例如:
In Visual Studio, you should replace -Wl,--stack,
with /STACK:
in each of these according to this thread and others. For example:
target_link_libraries(<target> PRIVATE "/STACK:10000000")
这篇关于Clion中C程序的堆栈大小增加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!