Global variables are not necessarily bad, just as macros are not necessarily bad, and enriched uranium is not necessarily bad. As long as you make a conscious decision about the pros and cons of a given design choice, you should be all right.
Some of the arguments against global variables are:
- They violate good object-oriented design
- They make your code difficult to unit-test, since you can not test individual blocks of code without setting up all of the global variables that the code expects to see
- They increase coupling in your code: actions in one block of code may affect things in another block of code in unpredictable ways via a shared global variable
Some of the arguents for global variables:
- They make it easy to share a single resource between many functions
- They can make code easier to read
If, in your design, global variables make sense, and can be used to make your code simpler to read or easier to maintain, without setting yourself up for random errors and testing headaches, then by all means use them.
I write a lot of C code for embedded microcontrollers, and I use global variables all the time. In such a rigid system, global variables make sense. I'm aware of the potential drawbacks, but I have analyzed the pros & cons and I write my code so as to guard against the major pitfalls.
Bottom line: There is no hard and fast rule. Just make the best decision for your particular project or platform, based on the best information that you have.