What is a good solution to prevent duplicate variables?
Posted on 2016-10-31
Our language is embedded 'C'.
We have global static unsigned int variable called vehicle_speed. A lower level function is called to fetch vehicle speed and assign to this variable.
We are adding a new software module that also needs vehicle speed. In a new file, I can create another global static unsigned int variable called vehicle_speed_motor2. Then, I call same low level function to fetch vehicle speed and assign it to vehicle_speed_motor2.
To avoid Two variables, I can create global variable but we think that would be too visible.
Are there any other solutions?