> Very confused by this. The C code declares an anonymous struct type, then aliases the typename "Foo" to that anonymous struct type. The C3 code seems to declares a named struct type "Foo" -- why isn't the C equivalent here just "struct Foo"?
I'm curious how familiar you are with C? In C++ you can do:
struct Foo {
// ...
};
Foo myVar;
But that's not how it works in C. In C this would be:
struct Foo {
// ...
};
struct Foo myVar;
Which is why many C developers typedef the struct so that they don't have to prefix struct types with the keyword.
> I don't think I can get further into the primer than this... even taking the author at their word that the two snippets are equivalent
Maybe don't judge the author on these things if you're not familiar with how C would work in this case? There's nothing wrong with not understanding a piece of code, but it's generally not a good idea to assume you have understanding of a language like C if you understand C++. People often conflate the two, but there are many quirks of C that C++ doesn't necessarily need to do and vice versa.
I'm curious how familiar you are with C? In C++ you can do:
But that's not how it works in C. In C this would be: Which is why many C developers typedef the struct so that they don't have to prefix struct types with the keyword.> I don't think I can get further into the primer than this... even taking the author at their word that the two snippets are equivalent
Maybe don't judge the author on these things if you're not familiar with how C would work in this case? There's nothing wrong with not understanding a piece of code, but it's generally not a good idea to assume you have understanding of a language like C if you understand C++. People often conflate the two, but there are many quirks of C that C++ doesn't necessarily need to do and vice versa.