Newsgroup: comp.lang.c++
Subject: =?ISO-8859-1?Q?=A73=2E5=2F6_in_the_C=2B=2B11_Standard?=
From: Ayrosa <jabelloc@...>
Date: Tue, 29 Apr 2014 12:44:18 -0700 (PDT)
§3.5/6
The name of a function declared in block scope and the name of a variable declared by a block scope extern declaration have linkage. If there is a visible declaration of an entity with linkage having the same name and
type, ignoring entities declared outside the innermost enclosing namespace scope, the block scope declaration declares that same entity and receives the linkage of the previous declaration. If there is more than one such matching entity, the program is ill-formed. Otherwise, if no matching entity is found, the block scope entity receives external linkage.[ Example:
static void f();
static int i = 0; // #1
void g() {
extern void f(); // internal linkage
int i; // #2 i has no linkage
{
extern void f(); // internal linkage
extern int i; // #3 external linkage
}
}
There are three objects named i in this program. The object with internal linkage introduced by the declaration in global scope (line #1 ), the object with automatic storage duration and no linkage introduced by the declaration on line #2, and the object with static storage duration and external linkage introduced by the declaration on line #3. --end example ]
Consider the i object in line #3. Why does it have static storage duration and external linkage?
Subject: =?ISO-8859-1?Q?=A73=2E5=2F6_in_the_C=2B=2B11_Standard?=
From: Ayrosa <jabelloc@...>
Date: Tue, 29 Apr 2014 12:44:18 -0700 (PDT)
§3.5/6
The name of a function declared in block scope and the name of a variable declared by a block scope extern declaration have linkage. If there is a visible declaration of an entity with linkage having the same name and
type, ignoring entities declared outside the innermost enclosing namespace scope, the block scope declaration declares that same entity and receives the linkage of the previous declaration. If there is more than one such matching entity, the program is ill-formed. Otherwise, if no matching entity is found, the block scope entity receives external linkage.[ Example:
static void f();
static int i = 0; // #1
void g() {
extern void f(); // internal linkage
int i; // #2 i has no linkage
{
extern void f(); // internal linkage
extern int i; // #3 external linkage
}
}
There are three objects named i in this program. The object with internal linkage introduced by the declaration in global scope (line #1 ), the object with automatic storage duration and no linkage introduced by the declaration on line #2, and the object with static storage duration and external linkage introduced by the declaration on line #3. --end example ]
Consider the i object in line #3. Why does it have static storage duration and external linkage?
via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1m8TcOw
View all the progranning help forums at:
http://ift.tt/1dP9txN
No comments:
Post a Comment