Does C struct have a runtime identifier?

I can refer to C struct with his name. In any case, it does not seem to have a runtime identifier. I mean, there is no symbol for the structure. It was transferred from header files. Therefore, I think that I can put a structure with the same name with different fields on several .c files without duplicate names.

I'm right? Or does C struct have a character, so should I avoid duplicate names?

PS. I apologize for the unclear conditions and the question, but at present I can only express it this way. I will update my question as I get more ideas.

+4
source share
2 answers

Struct tags do not have an anchor (in particular, they do not have an external anchor), so you do not need to worry about namespace conflicts between different translation units. In fact, their scope behaves to a large extent (exactly?) Just like the scope of variables, so you can even be local to a specific function or even a specific block in a specific function.

+2
source

If you ask if you can reuse the name of the structure to refer to different structures in different translation units, the answer is yes. I would not say that this is a good idea.

+7
source

Source: https://habr.com/ru/post/1394731/


All Articles