/Gs   (Control Stack Checking Calls)

OverviewHow Do ICompiler Options

The /Gssize option is an advanced feature with which you can control stack probes. A stack probe is a sequence of code that the compiler inserts into every function call. When activated, a stack probe reaches benignly into memory by the amount of space required to store the associated function’s local variables.

If a function requires more than size stack space for local variables, its stack probe is activated. The default value of size is the size of one page (4K for 80x86 processors). This value allows a carefully tuned interaction between an application for Win32 and the Windows NT virtual-memory manager to increase the amount of memory committed to the program stack at run time.

Warning   The default value of size is carefully chosen to allow the program stack of applications for Win32 to grow at run time. Do not change the default setting of /Gs unless you know exactly why you need to change it.

Some programs, such as virtual device drivers, do not require this default stack-growth mechanism. In such cases, the stack probes are not necessary. You can stop the compiler from generating stack probes by setting size to a value that is larger than any function will require for local variable storage. No space is allowed between /Gs and size.

The /Gs option with a size of 0 has the same result as the /Ge option.

You can turn stack probes on or off by using #pragma check_stack. Note that the /Gs option and the check_stack pragma have no effect on standard C library routines; they affect only the functions you compile.