The fifth example in [dcl.link]/4 states the following:
extern "C" {
static void f4(); // the name of the function f4 has internal linkage (not C language linkage)
// and the function’s type has C language linkage.
}
Why is this? Why is it the case that the name of the function f4
has internal linkage, and not a C language linkage?
P.S.: I'm asking this from a perspective of a language-lawyer. That is, how can one derive the commented statement above, from normative paragraphs in the Standard?
Internal linkage refers to everything only in scope of a translation unit. 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).
A linkage function is an essential prerequisite for hierarchical cluster analysis . Its value is a measure of the "distance" between two groups of objects (i.e. between two clusters).
To use internal linkage we have to use which keyword? Explanation: static keyword is used for internal linkage.
Explanation: External Linkage-> means global, non-static variables and functions. Internal Linkage-> means static variables and functions with file scope. None Linkage-> means Local variables.
From that same section, emphasis mine:
In a linkage-specification, the specified language linkage applies to the function types of all function declarators, function names with external linkage, [...]
But, f4
is declared static
, which means that name has internal linkage per [basic.link]/3:
A name having namespace scope has internal linkage if it is the name of:
- a variable, function or function template that is explicitly declared
static
; or, [...]
Hence, the C linkage doesn't apply.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With