C++ › Compilation & Linking

What is internal versus external linkage?

Advanced

Answer

External linkage means a name is visible across translation units (can be referenced from other files)—the default for non-const globals and functions. Internal linkage confines a name to its translation unit—given by static at namespace scope or an anonymous namespace, or by const/constexpr namespace-scope variables. Linkage controls symbol visibility and helps avoid multiple-definition clashes.
static int helper();     // internal linkage
int globalCounter;       // external linkage
Real-world example Marking a file-local helper static (internal linkage) prevents a symbol clash with a same-named function elsewhere.

Common follow-ups: What gives internal linkage? | What is the default for functions?