Are variables global or local? Or does the languate follow the more universal C++ norms?
Asking becuase I want to know if if I modify a normally defined variable ( global) inside a function, if it needs to be passed back to the main loop or if the variable is modified globally.
thanks
PS, I are total programming newb... Please forgive my (probably obvious) questions that I should probably know already...
@dxw00d - unless, of course, a variable is declared outside of a function definition with the static qualifier (in which its scope is global only within the file/translation unit in which it appears).
Functions with the static qualifier also have their scope limited to the file/translation unit in which they appear.
If you can, try to avoid the use of global variables. If you have to use globals then use statics to limit the scope to a particular module and then use access methods to get access to static module variables.
If you do need globals then wrap them up in a structure and pass a pointer to that structure to other functions, in this way you are only passing the size of a pointer onto the stack. Avoid referencing globals inside functions, instead pass in the pointer to the structure.