我想知道编译器内部发生了什么...... 比如是否将全局变量存储在不同的位置。
最佳答案
有关符号表的维基百科页面可以为您提供基本的了解。
http://en.wikipedia.org/wiki/Symbol_table
In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier in a program's source code is associated with information relating to its declaration or appearance in the source, such as its type, scope level and sometimes its location.
[...]
A common implementation technique is to use a hash table implementation. A compiler may use one large symbol table for all symbols or use separated, hierarchical symbol tables for different scopes.
强调我的。
关于c++ - 编译器如何知道变量是全局变量还是局部变量(C ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13342587/