Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What is a good solution to prevent duplicate variables?

Status
Not open for further replies.

jani12

Advanced Member level 4
Joined
Oct 30, 2014
Messages
107
Helped
0
Reputation
0
Reaction score
1
Trophy points
1,296
Activity points
2,527
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?
 

First solution - use structures.
Second - limit scope of variables.
Third - use pointers.
Fourth - use enumirated array
and e.t.c.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top