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!
{{Short description|Computer programming, a variable accessible throughout a computer program}} {{refimprove|date=July 2009}} In [[computer programming]], a '''global variable''' is a variable with global [[scope (programming)|scope]], meaning that it is visible (hence accessible) throughout the program, unless [[Variable shadowing|shadowed]]. The set of all global variables is known as the ''global environment'' or ''global state.'' In [[Compiled language|compiled languages]], global variables are generally [[static variable]]s, whose [[Variable (programming)#Scope and extent|extent]] (lifetime) is the entire runtime of the program, though in [[Interpreted_language|interpreted languages]] (including [[command-line interpreter]]s), global variables are generally dynamically allocated when declared, since they are not known ahead of time. In some languages, all variables are global, or global by default, while in most modern languages variables have limited scope, generally [[lexical scope]], though global variables are often available by declaring a variable at the top level of the program. In other languages, however, global variables do not exist; these are generally [[modular programming]] languages that enforce a module structure, or [[class-based programming|class-based]] [[object-oriented programming language]]s that enforce a class structure.
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)