C++ "namespace scope"

标签 c++ namespaces extern specifications

C++ 规范( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf ,第 7.5.4 节)指出

A linkage-specification shall occur only in namespace scope

“命名空间范围”到底是什么意思?这是否意味着链接规范(例如 extern "C")不能在全局范围内,只能在命名空间中?
“命名空间范围”到底是什么意思?

最佳答案

这意味着,extern "C" 应该只在命名空间范围内(而不是类范围、 block 范围等)。某些东西,不在命名空间内,但在全局范围内- 位于全局命名空间范围内。

The potential scope denoted by an original-namespace-name is the concatenation of the declarative regions established by each of the namespace-definitions in the same declarative region with that original-namespace-name.

关于C++ "namespace scope",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19541086/

相关文章:

c++ - 套接字窗口异常。读取访问冲突

c++ - 将 HLSL 像素着色器应用于 Win32 屏幕捕获

c - 关于 extern 关键字的使用

c++ - 将文件读入 char 数组,然后计算 strlen 卡在 C++ 中

c++ - C++ 中的高效线程安全单例

c# - 公共(public) API 的正确命名空间

python - 删除变量中的变量

php - 如果特定型号不在\App 中,则无法找到该型号

c++ - 如何在不同文件中使用 C++ extern 常量作为模板参数

constants - MQL4 - 如何在 MQL4 脚本中将 "today"-datetime 设置为外部变量?