Are there stackless or heapless implementation of C++?

后端 未结 7 1806
旧时难觅i
旧时难觅i 2020-11-29 09:32

C++ standard does not mention anything about the stack or the heap, they are implementation specific, which is true.

Even though they are not part o

7条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 09:59

    There can't be a stack-less and heap-less implementation since C++ defines constructs such as functions and the new operator. Calling a function requires a stack, and "new"ing up an instance requires a heap. How those are implemented can be different between platforms, but the idea will be the same. There will always need to be a memory area for instance objects, and another memory area to track the execution point and call hierarchy.

    Since x86 (and x64) have convenient facilities for these things (ie. the ESP register), the compiler uses that. Other platforms might be different, but the end result is logically equivalent.

提交回复
热议问题