在vscode终端terminal加大栈空间How to increase max stack size in c++ using vscode

参考:https://devpress.csdn.net/cloud/63268204fd0b112779162383.html
Answer a question
In many dynamic programming and graph problems it is required to do long depth recursion.

I am currently using vscode and mingw in windows for my c++ programs. But in default,as per my knowledge windows has 1MB max stack size .So I gets segmentation fault / stackoverflow problems. I know pretty well that I can change every recursion in loop,but i don’t wanna that stuff.

In some programming contest like Google Hashcode,Facebook Hackercup , they give large input and if I run that input in my machine it faces segmentation fault / stackoverflow problems.

Now what i need is to increase max stack size.

I found some approaches and here is my questions.

g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 Untitled1.cpp -o a.exe It works pretty well when I use this command in windows command prompt. But it gives error in vscode terminal(i don’t know why.) I found this command here.
在这里插入图片描述
I found somewhere #pragma comment(linker, “/STACK:2000000”), but i didn’t understood this clearly.

Is there anyway to change max stack size once in vscode, so that i do not need to specify every time when i compile ?

I just want to increase max stack size ,

Answers
VSCode uses powershell as its shell and commas are special characters for powershell. You need to put them inside quotes.

g++ -O2 -std=c++11 -Wall "-Wl,--stack=268435456" Untitled1.cpp -o a.exe

should work.

在vscode中本质上只需要把-Wl,–stack=268435456加上引号即可

相关推荐

  1. Terminator 命令行终端

    2024-03-27 08:36:04       64 阅读
  2. VSCode, 请windows下使用git bash终端

    2024-03-27 08:36:04       25 阅读
  3. Ubuntu终端多窗口分屏Terminator优化

    2024-03-27 08:36:04       31 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-27 08:36:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-27 08:36:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-27 08:36:04       87 阅读
  4. Python语言-面向对象

    2024-03-27 08:36:04       96 阅读

热门阅读

  1. Docker in Docker:揭秘原理,实战带你飞

    2024-03-27 08:36:04       37 阅读
  2. 精通c++系统编程

    2024-03-27 08:36:04       40 阅读
  3. JVM介绍

    JVM介绍

    2024-03-27 08:36:04      39 阅读
  4. 北斗导航 | 卫星导航领域会议汇总

    2024-03-27 08:36:04       47 阅读
  5. caffe | caffe源码中添加upsample层

    2024-03-27 08:36:04       36 阅读
  6. Spring Boot

    2024-03-27 08:36:04       38 阅读