07-27-2023, 09:59 AM
Apparently,
> For reasons that reach into the prehistory of C, it is possible to declare a struct and a non-struct with the same name in the same scope. - (*Bjarne Stroustrup - The C++ Programming Language. 4th Edition*)
For example:
struct Ambig {};
// the struct must be referred to with the prefix struct
void Ambig(struct Ambig* buf) {}
I'm just curious what the initial reason was? Without understanding, it seems like an example of bad language design, that causes ambiguity and is confusing.
> For reasons that reach into the prehistory of C, it is possible to declare a struct and a non-struct with the same name in the same scope. - (*Bjarne Stroustrup - The C++ Programming Language. 4th Edition*)
For example:
struct Ambig {};
// the struct must be referred to with the prefix struct
void Ambig(struct Ambig* buf) {}
I'm just curious what the initial reason was? Without understanding, it seems like an example of bad language design, that causes ambiguity and is confusing.