项目使用了C++开发,但是代码调用的层级非常深,如:
A::b()==>C::d()==>E::f()==>G::h()==>H::i()==>J::k()
一层一层下去,有10几层,请问下各位大佬,这样的代码除阅读不便之外,
对代码执行和性能有什么影响吗,需不需要优化
默认堆栈大小可能不够用
手动设置大点
/STACK (Stack Allocations)
Home | Overview | How Do I | Linker Options
The Stack Allocations (/STACK:reserve[,commit]) option sets the size of the stack in bytes.
To find this option in the development environment, click Settings on the Project menu. Then click the Link tab, and click Output in the Category box. The Reserve text box (or in the reserve argument on the command line) specifies the total stack allocation in virtual memory. The default stack size is 1 MB. The linker rounds up the specified value to the nearest 4 bytes.
The optional value specified in the Commit text box (or in the commit argument on the command line) is subject to interpretation by the operating system. In Windows NT, it specifies the amount of physical memory to allocate at a time. Committed virtual memory causes space to be reserved in the paging file. A higher commit value saves time when the application needs more stack space, but increases the memory requirements and possibly the startup time.
Specify the reserve and commit values in decimal or C-language notation.
Another way to set the size of the stack is with the STACKSIZE statement in a module-definition (.DEF) file. STACKSIZE overrides the Stack Allocations (/STACK) option if both are specified. You can change the stack after the .EXE file is built by using the EDITBIN tool.