RE: static_vars

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

 



This variable hiding is done by compiler at compile time.
It's the compiler which writes the assembly code to define the static
and all other variable. It defines the static variables in Data Segment.
Now compiling other files it keeps check that if that file is accessing
the static variable defined in other file, it should give a compile
error and should not compile it.

There is nothing at machine level which can block a peace of code
defined in other file to restrict access to static variable defined in
some other file.

Try the following:

- Try to write a small code in C language with static variable defined.
Now write a small assemble code in another file and access that static
variable.

- Now compile the .c file and assemble the assembly file seperatily.
Once it has been done, link both of these to create the executable. Now
run the executable, the code defined in assembly file will be able to
access the static variable defined in .c file.

It is nothing other than compiler which is restricting our access to
static variable defined somewhere else. At machine level (run time)
everything is accessible in process address space.

Regards,
Gaurav



-----Original Message-----
From: kernelnewbies-bounce@xxxxxxxxxxxx
[mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of prasanna wakhare
Sent: Thursday, July 22, 2004 3:31 PM
To: kernelnewbies@xxxxxxxxxxxx
Subject: static_vars

hi all,
As we know the static variables are only visible to a
file in which they declared,that is its defination is
not visible outside,
But as all variables are stored in data degment 
of the process what is internal mechanism to prevent
some other process ,or specifically from some other
file
to access it,Is thoses are read only or what
thanls 
Prasanna


	
		
__________________________________
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!
http://advision.webevents.yahoo.com/yahoo/votelifeengine/

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



--
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