We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Not Keil specific; one for the 'C' experts:
Why would one put 'static' variables definitions in a header?
eg, in a header file:
/* * TCO count to temperature conversion table. */ static erTcoTableStruct tcoTableOPUS1[] = { /*{TCO,Temp,} */ {1,-99}, {4,-45}, {5,-40}, {8,-35}, {11,-30}, {16,-25}, {22,-20}, {29,-15}, {37,-10}, {48,-5}, {61,0}, {78,5}, {99,10}, {124,15}, {153,20}, {188,25}, {227,30}, {270,35}, {315,40}, {365,45}, {420,50}, {481,55}, {549,60}, {625,65}, {710,70}, {805,75}, {910,80}, {1010,85}, {1060,88} };
AIUI, the whole point of so-called "header" files in 'C' is to share stuff between source files;
But the whole point of the 'static' keyword (at file scope) in 'C' is to make stuff private so that it is not visible to other modules - ie, not shared.
So I can't see why one would want to have 'static' definitions in a header?!
OK - if that is your philosophy, that's fair enough.
But, presumably, this requires a mechanism to ensure that "file-local" (ie, "internal linkage") variables are not repeated in other files?
Thanks for the 'fair enough' comment.
And yes, the "required" mechanism is my
#ifdef UART_Module // Data Allocation #else // Data reference #endif
construct.
(Not to mention my "uber" #include "Headers.H" file total control freak method of inclusion).
--Cpt. Vince Foster 2nd Cannon Place Fort Marcy Park, VA
But that's where it gets a bit confusing!
The whole point of making something static is so that it can not be externally referenced!
So, in this case, would you have, say:
#ifdef UART_Module static char private_uart_char; #else // No reference for private_uart_char #endif
yes?