c++ - 编译器如何知道变量是全局变量还是局部变量(C )

标签 c++ c compiler-construction

我想知道编译器内部发生了什么...... 比如是否将全局变量存储在不同的位置。

最佳答案

有关符号表的维基百科页面可以为您提供基本的了解。

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/

相关文章:

c++ - 在具有字节序兼容性的 C++ 中将 2 字节整数转换并分解为 2 个不同的字符

c - 在 For 循环中一行输出 2 个值 - C

language-agnostic - 是否有任何 self 改进的编译器?

c++ - 指向数组访问的指针出现段错误

C++: union 与按位运算符

c++ - 基准换行符与 std::endl

c - 是否有任何 C 编译器会警告使用未声明的定义

c - 使用数组打印出一些星号,这取决于用户在 C 中输入的数字

.net - .NET 中类加载器的等效项

ubuntu - 找不到 C 编译器,Ubuntu