The storage class specifier 'static', when refered to a variable, have 2 properties: the variable is allocated in BSS section and retain its contents during program existence, the second is that its scope is limited to the declaration instance and never outside the module where it is declared (a static declared variable cannot be accessed with the 'extern' qualifier).
This means that you always occupy the memory of that instance from the start to the end of the program.
You can have as many instances of static variables with the same name as you want while they are outside of the scope of each other. You can have any number of instancies of your structure at whichever scope if they have different names.
This means that you always occupy the memory of all instances from the start to the end of the program.
See this example:
typedef _tagMyStruct
{
int a;
struct _tag_Struct2
{
float c;
int d
} MySecondStruct;
} MyExampleStruct;
static MyExampleStruct MyStruct;
int foo(void)
{
static MyExampleStruct MyStruct;
...
}
int bar(void)
{
static MyExampleStruct MyStruct;
...
}
int fun(void)
{
...
}
A structure declaration cannot be declared static, but its instancies can.
You cannot have static members inside a structure because the members of a structure inherist the storage class of the containing struct. So if a structure is declared to be static all members are static even included substructures. But if you include
pointers to structures (as in your sample) of course the sub structures have the storage class of their respective instances.