HOWTO: Specify Stack Size (Clarification)

Last reviewed: September 2, 1997
Article ID: Q50950

The information in this article applies to:
  • The Microsoft C/C++ Compiler (CL.EXE) and the Microsoft Linker (LINK.EXE) included with: - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, 6.0ax - Microsoft C for OS/2, versions 5.1, 6.0, 6.0a - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0, 1.5 - Microsoft Visual C++, 32-bit Edition, versions 1.0, 2.0, 4.0, 5.0

SUMMARY

With the Microsoft C compiler, the choice to use the /F compiler option or the /ST linker option to specify a stack size for a program depends on the method being used to compile and link.

MORE INFORMATION

If you using the CL command to compile and link, the /F compiler option is all that is necessary. This option will pass the correct size of the stack to the linker.

Conversely, if you are invoking the compiler and the linker separately (as in a MAKE file), the /ST link option can be used to get the desired stack size.

No stack information is stored in the object module. Therefore, using the /F and /c (compile only) options together and then invoking link separately will not generate the desired stack size.

For OS/2, Windows, Windows NT, and Windows 95 applications, the stack size can be specified in the .DEF file using the STACKSIZE directive. STACKSIZE overrides the size specified on the link line.

For 16-bit linkers, the default stack size is 2K. If an odd value is specified for the stack size, the linker will round it up to the next even value. For 32-bit linkers, the default stack size is 1MB. The linker rounds up the specified value to the nearest 4 bytes.


Additional query words: 8.00 8.00c 9.00
Version : MS-DOS:6.0,6.00a,6.00ax,7.0; OS/2:6.0,6.00a; WINDOWS:1.0,1.5; WINDOWS NT:1.0,2.0,4.0,5.0


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.