Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Global variable
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Use== Interaction mechanisms with global variables are called '''global environment''' (see also '''global state''') mechanisms. The global environment paradigm is contrasted with the [[local environment]] paradigm, where all variables are [[subprogram#Local variables, recursion and reentrancy|local]] with no [[Shared memory (interprocess communication)|shared memory]] (and therefore all interactions can be reconducted to [[message passing]]). Global variables are used extensively to pass information between sections of code that do not share a caller/callee relation like concurrent threads and signal handlers. Languages (including C) where each file defines an implicit namespace eliminate most of the problems seen with languages with a global [[namespace]] though some problems may persist without proper encapsulation. Without proper locking (such as with a [[mutex]]), code using global variables will not be [[thread-safe]] except for read only values in [[protected memory]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)