What is "global-variables"

They are generally considered a bad practice precisely because of their non-locality: a global variable can potentially be modified from anywhere (unless they reside in protected memory or are read-only)and any part of the program may depend on it. Therefore, a global variable has unlimited potential for creating mutual dependencies, and the addition of mutual dependencies increases complexity. However, in some cases global variables may be suitable for use. For example, they can be used to avoid the need to pass the variables most frequently used continuously over various functions. Global variables also make it difficult to integrate modules because software written by others can use the same global names unless names are reserved by agreement, or by naming convention.   Global variables are widely used to transmit information between code sections that do not share a caller/receiver relationship such as threads simultaneous and signal manipulators. Languages (including C) where each file defines an implicit namespace eliminate most of the problems seen with languages with a global namespace, but some problems may persist without proper encapsulation. Without proper locking (as with a mutex), code using global variables will not be thread-safe, except to read only the values in protected memory.