Question: Are the tags on structures that are declared as static at file scope private to the file in the same way that the actual struct variable being declared will be? Or are the structure tags common across files?
This question came from a problem I am having with the MSVS2019 debugger showing me the wrong values and struct member names in some files. (You can read about the bug here, if you're interested: Visual Studio 2019 Debugger Issue) The files were all cloned from an original and all have something like this:
static struct MyPrivateData_s
{
char *szData[64];
} myData;
static int myCount;
The actual members of the struct vary from file-to-file and the values are quite different for each.
I know that variables that are declared static, but above any functions in a source file have "file scope" -- are global to that file only. I'm pretty certain the VS debugging system has a problem, but it made me wonder about how (or even if) the static storage class affects the structure tag.
If the tag is treated like the name of the struct and other variables, then it is private to the file. However, if the tag is treated differently, it may be triggering the VS bug. Remember, I am asking about only the structure tag, not the name of the actual structure variable. It would also be good to know how names from a typedef are affected by 'static' as well.
I have been trying to find the answer in all of the various C references I own and can find on line, but I (a) don't know the right question to ask and/or (b) am not understanding (or recognizing?) the answer when I find it. Hopefully a C guru can help me out.
FWIW, I think that anything following static at file scope should be restricted to the file where it is found. In fact, only below the point it is found in the file. That is how I have always coded and I have never encountered an issue before this debugger thing made me wonder about this. Thanks!
I think this may answer my question: Limit Struct Scope even though it does not explicitly use the term "tag". Instead, it appears to be calling the tag a "type", which, it becomes when prefixed by 'struct'. So static has no effect, but the fact that the tag appears in a C file and NOT in a common header means that the tag is private to the file. Sorry to have been a bother.