Globals
Global variables, are those things that hold a state and any function can use. If these variables are public, every function outside the library will also be able to use. There is also the aspect of global constants, which behave exactly like global variables except they are read-only.
They are declared inside a library, and the syntax is: ((constant) type varname ( = initialvalue)
). Adding the constant prefix makes the global a constant (which means it is read-only, in that case the initial value is mandatory, else it is optional. Another variation is when you want arrays. You can use name[]
for an array with default size ( 8191), name[SIZE]
for an array with another size value (which may be bigger, but if it is bigger than 8191, it will need function calls to be read), name[SIZE1][SIZE2]
for a 2D array, the total storage needed for this array is SIZE1*SIZE2
. Arrays cannot be assigned to an initial value.
You may also separate globals of the same type using a comma.