I have a legacy C function which uses a struct definition as follows
struct{
float _schedulerRate;
}sched_;
#define sched_1 sched_;
// bla bla bla
myFunc(bla bla bla) {
// Lots of bla bla bla
someVar = some_complicated_equation/sched_1._schedulerRate;
// More bla bla bla
}
This function does not even accept any argument that somehow gets assigned to the sched_1._schedulerRate
element. I also know that I cannot define the struct using extern
because this linkage does support sturct definitions.
The problem is that when I am unit testing it, I have to set a value for this sched_1._scheduerRate
. How can I do this? This is a legacy code that runs successfuly but I am trying to integrate one of its modules for a side project.
I have only 1.5 years experience in C/C++ programming and may be that's why I don't know some magic tricks. But even from a novice user's PoV, this looks almost impossible for me to do. However, it is legacy code and works too! how I don't know.