Re: avr-gcc : .bss always set variables to zero ?

In article <3cv5skF6m64rsU1@xxxxxxxxxxxxxx>, Not Really Me wrote:
> Stated simply, if you need something to be zero you should specify an
> initial value or declare it static

No; "static storage duration" does not only mean "with the
storage-class specifier static." Note the "or" in section 6.2.4 you

"An object whose identifier is declared with external or internal
linkage, OR with the storage-class specifier static has static storage

According to 6.2.2, a non-static global has external linkage:

"If the declaration of an identifier for an object has file scope and
no storage-class specifier, its linkage is external."

And thus has static storage duration, and thus is initialized.

John W. Temples, III


Relevant Pages

  • Re: Shared Objects Libraries and Symbols...
    ... ~ 1 An identifier declared in different scopes or in the same scope more ... There are three kinds of linkage: ... each declaration of an identifier with internal ... ~ 4 For an identifier declared with the storage-class specifier extern ...
  • Re: Yet another brute force sudoku solver
    ... it) since anyone can declare an extern and then see it. ... declaring the same identifier with external ... linkage in a different translation unit will not make this definition ...
  • Re: redeclaration of p with no linkage
    ... int main ... you tried to declare it again. ... Both declarations don't specify the linkage - that is, ... that the object is extern (external linkage) or static (internal ...
  • Re: Multiple definitions of variables in C
    ... "2 A declaration of an identifier for an object that has file scope without ... without a storage-class specifier or with the storage-class specifier ... If a translation unit contains one or more tentative ... with an initializer ...
  • Re: Array definition guarantees
    ... variable not declared as `extern' has no linkage at all; ... I did not realize one has to explicitly declare a variable ... char a has static duration, ...