Why are struct tags not type names in C?

I am curious to motivate this behavior in C. Was it intentional or accidental?

struct tpoint // tpoint is not a type name
{
    int x, y;
};

typedef struct tpoint Point; // point is a type name.

I want to know why Ritchie or the standard committee chose this behavior.

+5
source share
2 answers

This is a thing with names. Thus, I have struct a, enum a, union aand none of them is ambiguous. This helps in developing frameworks that can have similar type names, but they can get confused quickly.

+4
source

In reading C language development , when Dennis Ritchie discusses embryonic C, he describes his intention for struct:

, , , .

, " ↔ ". C (a struct " " ).

, ++ struct class, , . A class - - , , .

0

All Articles