The answer is depending on the language (you tagged both C
and C++
).
In C
it is not possible if the structure definition is known. You may be able to implement an encapsulated module where only the pointer to a struct is exposed, but such an implementation might be rather limited. For a plugin-system this might be usefull though.
In C++
you can do this implicitly via a Singleton
pattern. However this wouldn't prevent you from having multiple variables, as shown in your example, it only ensures that all these variables are using the same instance. It would also give no error, at least no compile error. You could throw a runtime error though.