Search code examples
c++language-lawyerexternlinkage

"extern string-literal declaration" within function scope


from [dcl.link]#2 :

extern string-literal declaration

the paragraph does not specify any special cases for declaration within a function scope, but following does not compile also :

void foo () { extern "C" int boo () ; }

from g++ output :

error: expected unqualified-id before string constant

so is it a g++'s bug or i have missed something.?


Solution

  • The linkage-specification is part of declaration which is part of declaration-seq which can be part of a namespace-body or a translation-unit.

    Nowhere in the grammar is it allowed in a function, which uses block-declaration, which is almost the same as declaration but is notable missing linkage-specification.