In C, is there a difference between writing ‘struct foo’ instead of just ‘foo’ if foo is a struct?
For example:
struct sockaddr_in sin; struct sockaddr *sa; // Are these two lines equivalent? sa = (struct sockaddr*)&sin; sa = (sockaddr*)&sin;
Thanks /Erik
In fact, in standard ‘C’ it’s required to specify
structkeyword. This is optional in C++.This is the reason some people define structs like this:
to be able to use
barinstead ofstruct foo. However, some C compilers do not enforce this rule.