How do internal, external, and no linkage determine whether declarations across scopes or translation units denote the same C++ entity?
Show answer and explanation
Linkage describes whether declarations of a name can denote the same entity beyond one scope or translation unit; it is distinct from visibility, storage duration, and C versus C++ language linkage. Namespace-scope functions and ordinary non-const variables normally have external linkage. An explicit namespace-scope static declaration and names in an unnamed namespace have internal linkage, so each translation unit gets its own entity. A non-template, non-volatile const namespace-scope variable also normally has internal linkage unless rules such as extern, inline, a prior declaration, or module attachment change it. Ordinary block-local names have no linkage. Inline permits an eligible externally linked definition to appear in multiple translation units as one entity; it does not simply mean per-translation-unit state. Header design must intentionally choose a shared inline entity, a single external definition, or isolated internal state.
Linkage describes whether declarations of a name can denote the same entity beyond one scope or translation unit; it is distinct from visibility, storage duration, and C versus C++ language linkage. Namespace-scope functions and ordinary non-const variables normally have external linkage. An explicit namespace-scope static declaration and names in an unnamed namespace have internal linkage, so each translation unit gets its own entity. A non-template, non-volatile const namespace-scope variable also normally has internal linkage unless rules such as extern, inline, a prior declaration, or module attachment change it. Ordinary block-local names have no linkage. Inline permits an eligible externally linked definition to appear in multiple translation units as one entity; it does not simply mean per-translation-unit state. Header design must intentionally choose a shared inline entity, a single external definition, or isolated internal state.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.