Re: static declarations in structs

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

 



On Wed, 2004-08-18 at 06:27 -0700, Anandraj wrote:
[...]
> > > 2.How does the complier diffrenciate between a Global Variable and
> > > Static Variable as both of them will be in the same stack?
> > 
> > Neither are on a stack.  The difference is scope.  The statics are local 
> > to either a file or a function (depending on where that are defined).
> 
> IIRC , i guess both the global and static variables have their memory
> allocated from Stack ??!!!

Global variables always in the data segment. Static global variables are
not exported, so the linker does not know them. Auto global variables
are seen by the linker and can be referenced from other .c files.

Static local variables (read: variables declared inside a function) are
in the data segment, but logically only accessible from that function.
Auto local variables are on the stack (and logically only accessible
from that function).

> Plz correct me if im Wrong !

[ Fullquote killed ]

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux