I have the following structure:
test.h:
extern BOOL some_variable;
inline BOOL get_some_variable()
{
return some_variable;
}
test.c
BOOL some_variable = 10;
// some functions that change 'some_variable'.
main.c
int main()
{
while(1) {
if (get_some_variable()) { // do something }
}
}
My question is, will this work as expected. By that I mean will call in main get replaced by 'some_variable'? Or will this create copies of 'some_variable' or something like that? Does the inlined function need to be declared extern somewhere?
I am aware I could just be checking 'some_variable' in main.c without the need of a function, but this way seems more elegant to me. Or is there a better way, to have a variable in other source file returned without calling a function. I want this to reduce the number of operations needed to get 'some_variable' because this is for a microcontroller.