Re: Global Definition Vs Global Declaration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Unless my knowledge of C is wrong here, both 'int i' and 'extern int i' are
> indistinguishable declarations (not definitions).  An explicit initialization
> would be needed to make the second a definition: int i = 0.  Isn't this the
> case here?

Explicitly initializing the variable only has effect on where the
variable is allocated space. In this case, explicit initialization
moves the variable out of the common area into the data segment.
Hence, DECL_COMMON returns 0 when we do this. The point being, both
are definitions. Where as an extern declaration is an explicit
reference to an externally defined variable (which can be outside the
current translation unit). Please correct me if I am wrong on this.
Appreciate your help.

Zahed



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux