Clone via HTTPS Clone with Git or checkout with SVN using the repository’s web address.
-->Sets the program stack size in bytes.
Syntax
/Fnumber
Arguments
number
The stack size in bytes.
Remarks
Without this option the stack size defaults to 1 MB. The number argument can be in decimal or C-language notation. The argument can range from 1 to the maximum stack size accepted by the linker. The linker rounds up the specified value to the nearest 4 bytes. The space between /F and number is optional.
You may need to increase the stack size if your program gets stack-overflow messages.
You can also set the stack size by:
Using the /STACK linker option. For more information, see /STACK.
Using EDITBIN on the .exe file. For more information, see EDITBIN Reference.
To set this compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.
Select the Configuration Properties > C/C++ > Command Line property page.
Type the compiler option in the Additional Options box.
To set this compiler option programmatically
- See AdditionalOptions.
C++ Stack Size Limit
See also
C++ Increase Stack Size
MSVC Compiler Options
MSVC Compiler Command-Line Syntax
abhishek@bjlinux028 ~/dev/c> cat test-stack_ok.c |
#include <stdio.h> |
#define BUF_SIZE (16*1024*1024) |
int main(void) { |
char buf[BUF_SIZE]; |
printf('%lun', sizeof(buf)); |
return 0; |
} |
abhishek@bjlinux028 ~/dev/c> gcc -Wall -Wextra -Werror test-stack.c |
abhishek@bjlinux028 ~/dev/c> ./a.out |
Segmentation fault (core dumped) |
abhishek@bjlinux028 ~/dev/c> gcc -g -Wall -Wextra -Werror test-stack.c |
abhishek@bjlinux028 ~/dev/c> gdb a.out |
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1) |
Copyright (C) 2010 Free Software Foundation, Inc. |
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> |
This is free software: you are free to change and redistribute it. |
There is NO WARRANTY, to the extent permitted by law. Type 'show copying' |
and 'show warranty' for details. |
This GDB was configured as 'x86_64-redhat-linux-gnu'. |
For bug reporting instructions, please see: |
<http://www.gnu.org/software/gdb/bugs/>... |
Reading symbols from /home/abhishek/dev/c/a.out...done. |
(gdb) run |
Starting program: /home/abhishek/dev/c/a.out |
Program received signal SIGSEGV, Segmentation fault. |
0x00000000004004e1 in main () at test-stack.c:7 |
7 printf('%lun', sizeof(buf)); |
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.132.el6_5.2.x86_64 |
(gdb) backtrace |
#0 0x00000000004004e1 in main () at test-stack.c:7 |
(gdb) disassemble |
Dump of assembler code for function main: |
0x00000000004004c4 <+0>: push %rbp |
0x00000000004004c5 <+1>: mov %rsp,%rbp |
0x00000000004004c8 <+4>: sub $0x1000000,%rsp |
0x00000000004004cf <+11>: mov $0x4005e8,%eax |
0x00000000004004d4 <+16>: mov $0x1000000,%esi |
0x00000000004004d9 <+21>: mov %rax,%rdi |
0x00000000004004dc <+24>: mov $0x0,%eax |
=> 0x00000000004004e1 <+29>: callq 0x4003b8 <printf@plt> |
0x00000000004004e6 <+34>: mov $0x0,%eax |
0x00000000004004eb <+39>: leaveq |
0x00000000004004ec <+40>: retq |
End of assembler dump. |
(gdb) exit |
Undefined command: 'exit'. Try 'help'. |
(gdb) q |
A debugging session is active. |
Inferior 1 [process 22960] will be killed. |
Quit anyway? (y or n) y |
abhishek@bjlinux028 ~/dev/c> ulimit -a |
core file size (blocks, -c) 0 |
data seg size (kbytes, -d) unlimited |
scheduling priority (-e) 0 |
file size (blocks, -f) unlimited |
pending signals (-i) 256107 |
max locked memory (kbytes, -l) 64 |
max memory size (kbytes, -m) unlimited |
open files (-n) 25000 |
pipe size (512 bytes, -p) 8 |
POSIX message queues (bytes, -q) 819200 |
real-time priority (-r) 0 |
stack size (kbytes, -s) 10240 |
cpu time (seconds, -t) unlimited |
max user processes (-u) 65535 |
virtual memory (kbytes, -v) unlimited |
file locks (-x) unlimited |
abhishek@bjlinux028 ~/dev/c> ulimit -a -p |
core file size (blocks, -c) 0 |
data seg size (kbytes, -d) unlimited |
scheduling priority (-e) 0 |
file size (blocks, -f) unlimited |
pending signals (-i) 256107 |
max locked memory (kbytes, -l) 64 |
max memory size (kbytes, -m) unlimited |
open files (-n) 25000 |
pipe size (512 bytes, -p) 8 |
POSIX message queues (bytes, -q) 819200 |
real-time priority (-r) 0 |
stack size (kbytes, -s) 10240 |
cpu time (seconds, -t) unlimited |
max user processes (-u) 65535 |
virtual memory (kbytes, -v) unlimited |
file locks (-x) unlimited |
abhishek@bjlinux028 ~/dev/c> ulimit -s32768 |
abhishek@bjlinux028 ~/dev/c> ulimit -a |
core file size (blocks, -c) 0 |
data seg size (kbytes, -d) unlimited |
scheduling priority (-e) 0 |
file size (blocks, -f) unlimited |
pending signals (-i) 256107 |
max locked memory (kbytes, -l) 64 |
max memory size (kbytes, -m) unlimited |
open files (-n) 25000 |
pipe size (512 bytes, -p) 8 |
POSIX message queues (bytes, -q) 819200 |
real-time priority (-r) 0 |
stack size (kbytes, -s) 32768 |
cpu time (seconds, -t) unlimited |
max user processes (-u) 65535 |
virtual memory (kbytes, -v) unlimited |
file locks (-x) unlimited |
abhishek@bjlinux028 ~/dev/c> |
abhishek@bjlinux028 ~/dev/c> ./a.out |
16777216 |