Search code examples
c++visual-studiostackstack-size

Stack size in multiple vs projects


Lets say I have a C++ Visual Studio solution with 5 projects A, B, C, D and E. The projects have set the /STACK linker option to:

  • A = 4MB
  • B = empty (by default 1MB)
  • C = empty (by default 1MB)
  • D = 16MB
  • E = 25MB

All of them are built as separate DLLs with exposed functions. Project:

  • A contains a function foo_a which calls foo_b (from B) and foo_c (from C)
  • B contains the function foo_b which calls foo_d (from D) and foo_e (from E)

What will be the stack size if I would call function A.foo_a ? Will it be the same if I would call directly E.foo_e ?


Solution

  • Manually started threads (with CreateThread) can get a custom size from the arguments of the function call, the main thread´s stack size is set accoring to informations from the EXE.

    Your five DLLs don´t matter at all.
    They can have a custom size set by the linker in their file header,
    but the OS won´t do anything with it.

    (The runtime stack size (on Windows) is per thread, not per file.)