Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: Initialization

Thread Tools

Re: Initialization

Ben Bacarisse
Posts: n/a
Russell Shaw <> writes:

> Hi,
> In gcc-4.7 C99, this gets accepted in a block scope:
> static int a = 1;
> ISO/IEC 9899:201x 6.7.8p5 says:
> If the declaration of an identifier has block scope, and the
> identifier has external or internal linkage, the declaration shall
> have no initializer for the identifier.

I think 6.2.2 p6 is the key thing here:

"The following identifiers have no linkage: an identifier declared to
be anything other than an object or a function; an identifier declared
to be a function parameter; a block scope identifier for an object
declared without the storage-class specifier extern."

In your example, 'a' has no linkage. For block scope declarations,
static alters only the lifetime of the object, not the linkage of the

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
what's the difference between value-initialization and default-initialization? Jess C++ 23 05-04-2007 03:03 AM
array initialization in initialization list. toton C++ 5 09-28-2006 05:13 PM
Initialization of non-integral type in initialization list C++ 6 12-11-2005 09:51 PM
Initialization via ctor vs. initialization via assignment Matthias Kaeppler C++ 2 07-18-2005 04:25 PM
Default Initialization Vs. Value Initialization JKop C++ 10 09-22-2004 07:26 PM