Quote:
|
Originally Posted by stephenthe1
I was reading about extern and static variables. I realize that it's considered bad coding technique to declare extern variables, because they are declared outside functions. however, I need this variable available to interrupts.c and user_routines_fast.c. however, I only want this variable to have its value assigned once. where should I place a variable that can be used in both these files, and have the variables value (unsigned int phase = 1000) assigned only once. I did search on google, but it doesn't exactly tell me about how the structure of the default code is set up to work with and where to put such a variable so it will be available to these particular files.
|
I don't know how it would be bad coding practice; any variable that needs to be accessable from 2 or more different functions
must be declared globally.
The variable should be declared in one file and extern'd in all the others you need it in.