stack growth direction

后端 未结 5 1578
慢半拍i
慢半拍i 2020-12-06 07:20

So from my previous memmove question I would like to know how to find direction of stack growth.

  void stackDirection(int* i)
  {

     int j;

     if(&         


        
5条回答
  •  无人及你
    2020-12-06 07:55

    Experiments such as this are unreliable, because you can run into exceptions. The optimiser can mess you up, or the system might use registers for parameters. If you really must know the stack direction, read the manual for your processor.

    Notwithstanding that, unless you are writing an operating system or something really low-level, if you need to know the stack direction you are probably doing something ugly and horrible and should really reconsider your methods.

提交回复
热议问题