Let's say I have thre project wide variable blocks with external linkage vByte[1000]
, vWord[1000]
and vQword[1000]
. And because of the lack of a better debug solution, every variable that I want to see at runtime has to be in those blocks.
Now I want to implement a set of functions in a module(compilation unit) that has a few important values that I want to be able to monitor. I came up with the following solutions to make a more clear access to these parts of the array, but I am unsure which to use.
At first I would declare the array extern vByte[1000];
in my module and the I would like to give a specific variable of the array a fitting name.
I could just #define
the variables I want to use: #define importantValue1 vByte[21]
and use them like this.
But I think it might be better to encapsulate the variable in my module, maybe like this:
static byte *importantValue1 = &vByte[21];
This would reinforce that this variable is for use in this module. Are there drawbacks to this or is the define just the straight forward approach with less overhead and no drawbacks?