Why cant register variables be made global?

后端 未结 9 1420
时光说笑
时光说笑 2021-02-06 13:33

While reading from a site a read that you can not make a global variable of type register.Why is it so? source: http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.js

9条回答
  •  南笙
    南笙 (楼主)
    2021-02-06 14:27

    So do we all agree now? Do we all see that making a global variable a register variable would be a really, really bad idea? If the original C definition did not forbid it, it was probably because nobody thought anyone would actually implement it that way -- as they should not have especially back in CISC days.

    Besides: modern optimizing compilers do a better job of deciding when to keep variables in registers than humans can do. If yours can't do it, then you really, REALLY need to get a better compiler.

提交回复
热议问题