This documentation is archived and is not being maintained.

/Gs (Control Stack Checking Calls)



The number of bytes that local variables can occupy before a stack probe is activated.


This option is an advanced feature to control stack probes. A stack probe is a sequence of code 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 n bytes of stack space for local variables, its stack probe is activated. The default value of n 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.

Note   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 n.

/Gs0 has the same effect as /Ge.

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.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
  2. Click the C/C++ folder.
  3. Click the Code Generation property page.
  4. Modify the Buffer Security Check property.

To set this compiler option programmatically

See BufferSecurityCheck Property.

See Also

Compiler Options | Setting Compiler Options