Comment by wavemode
12 hours ago
The main thing I dislike about typedefs is that you can't forward declare them.
If I know for sure I'm never going to need to do that then OK.
12 hours ago
The main thing I dislike about typedefs is that you can't forward declare them.
If I know for sure I'm never going to need to do that then OK.
How do you mean? You can at least do things like
typedef struct foo foo;
and somewhere else
struct foo { … }
The usual solution for this is:
Now you have a struct named 'bla_s' and a type alias 'bla_t'. For the forward declaration you'd use 'bla_s'.
Using the same name also works just fine, since structs and type aliases live in different namespaces:
...also before that topic comes up again: the _t postfix is not reserved in the C standard :)
Yes, using the same Gtk example, the way you’d forward declare GtkLabel without including gtklabel.h in your header would be:
Why are you complicating things? Struct and Unions are different namespaces for a reason.
works just fine.
People getting hung up on `_t` usage being reserved for posix need to lighten up. I doubt they'll clash with my definitions and if does happen in the future, I'll change the typedef name.