[cfe-dev] Why this extern "C" fails ?
Renato Golin
renato.golin at linaro.org
Tue Jul 30 04:01:27 PDT 2013
On 30 July 2013 09:08, David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:
> #include <iostream>
>
> int main() {
> {
> extern "C" int a = 42;
> { std::cout << a << "\n"; }
> }
> return (0);
> }
>
> This also fails to compile. I'm not sure what you'd expect the semantics
> to be. The variable a has automatic storage, and so a linkage specifier
> makes no sense in this context.
>
This code fails to compile because: "variable declarations with the extern
specifier at block scope refer to declarations that are members of an
enclosing namespace, but they do not introduce new names into that scope."
3.3.2-10.
Ajit, your example contains several invalid C/C++ semantics, I'm really not
sure how you got this code, or why you want to change the linkage semantics
of a local variable.
Honestly, you'd have more luck on dissecting the C++ standard at
comp.lang.c++, not here.
cheers,
--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130730/d88ab27b/attachment.html>
More information about the cfe-dev
mailing list