Volodymyr Boyko
Volodymyr Boyko

Reputation: 1581

"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.?

Upvotes: 2

Views: 141

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409166

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.

Upvotes: 5

Related Questions