什么是外部链接和内部链接? [英] What is external linkage and internal linkage?

查看:411
本文介绍了什么是外部链接和内部链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解外部联系和内部联系及其区别。

I want to understand the external linkage and internal linkage and their difference.

我也想知道


const 变量默认情况下内部链接,除非另行声明为 extern

const variables internally link by default unless otherwise declared as extern.


推荐答案

编写实现文件( .cpp .cxx 等),编译器会生成一个翻译单元。这是实现中的源文件以及您在其中 #include d的所有标头。

When you write an implementation file (.cpp, .cxx, etc) your compiler generates a translation unit. This is the source file from your implementation plus all the headers you #included in it.

内部链接仅指翻译单位范围内的所有内容

外部链接是指超出特定翻译单元的内容。换句话说,可通过整个程序访问,这是所有翻译单元(或目标文件)的组合。

External linkage refers to things that exist beyond a particular translation unit. In other words, accessible through the whole program, which is the combination of all translation units (or object files).

这篇关于什么是外部链接和内部链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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