Nick,
that sounds like exactly what I should be doing, it also sounds like the 'propper' way to define code, but I am not following how it works well.
Am I correct in assuming that the #define is a compiler directive that runs a macro at compile time producing repetitive code that is then compiled?
Sorry to be vague I have never done this before. Please correct / explain the following ...
#define MAKE_VAR(v) #v, &v
This code creates a macro that runs at compile time called MAKE_VAR which accepts an argument (v) 'v' is text as we are in a compiler evaluating text.
#v , &v are instructions that cause the macro to output the string "InputText", &InputText every time the compiler encounters MAKE_VAR(InputText).
I am assuming that # means enclose in " whilst ' , & ' are literals.
What is actually compiled is :-
xVar vals [] = {
{ "BatVolts", &BatVolts },
{ "ACVolts", &ACVolts },
{ "WindSpeed", &WindSpeed },
{ "PVCurrent", &PVCurrent },
};
This is both defining and populating the array so my function to fill the array with name value pair's is redundant.
Is that somewhere near?
Where would I find info on macro's, macros in this context obviously, I understand the basic concept of a macro.
Thanks
Al