如何与由系统识别不同功能的同名静态变量? [英] How are static variables with the same name in different functions identified by the System?

查看:134
本文介绍了如何与由系统识别不同功能的同名静态变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,我们可以有不同的功能,两个同名的静态变量?如何在这些编译器和符号表进行管理?如何他们的身份分开管理?

AFAIK, we can have two static variables with the same name in different functions? How are these managed by the compiler and symbol table? How are their identities managed seperately?

推荐答案

编译器不静态变量的名字存储在链接符号表。他们只是一些存储器是这样的模块的一部分,只要该连接基而言。 (这可能不是在所有情况下100%正确的,但是它是有效的真)

Compilers don't store static variables' names in the linking symbol table. They are just some memory that is part of the module as far as the linker is concerned. (this may not be 100% true in all cases but it is effectively true)

静态变量的名称,通常包含调试符号表中。

The names of static variables are usually included within the debugging symbol table.

当你喂.c文件将其与所有已知符号的名称保留,以便它可以识别它们因为他们是什么时,他们拿出未来code编译器。它还记得他们,以便它可以提供有用的错误/警告信息,但它$关于他们p $ ptty多忘生成输出文件时(除非正在生成调试符号)。

When you feed a .c file to the compiler it keeps up with the names of all known symbols so that it can recognize them for what they are when they come up in future code. It also remembers them so that it can give useful error/warning messages, but it pretty much forgets about them when generating output files (unless debugging symbols are being generated).

这篇关于如何与由系统识别不同功能的同名静态变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆