Search code examples
c++language-lawyerlinkage

Why is it the case that the name of the function f4 has internal linkage, and not a C language linkage?


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?


Solution

  • 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.