| 1. |
How Are Local And Global Variables Are Allocated By Compiler. |
|
Answer» Normally, cpu registers are allocated for local variables, but if the address of that local variable is used by some code, then it won’t ALLOCATE register but access from memory, THUS result in un-optimized code. Gobal variables always use memory, so access is slower, so always use global only when it is absolutely NECESSARY. Normally, cpu registers are allocated for local variables, but if the address of that local variable is used by some code, then it won’t allocate register but access from memory, thus result in un-optimized code. Gobal variables always use memory, so access is slower, so always use global only when it is absolutely necessary. |
|