Could someone outline the pros and cons of typedefing pointers to
structs like this?
typedef struct exp_ {
int val;
struct exp_ *child;
} *exp;
(This is straight from memory so it might not even compile.)
The use case is AST representation which makes heavy use of pointers to
structs (in fact IIRC it only uses pointers, never plain structs).
Right now I don't use typedefs since I read in the Linux kernel coding
guidelines that (the author believes) that it obfuscates what's really
going on. Note that pretty much every function in the compiler will
modify these structs so either the whole typedef will be in a .h file
or a bunch of access functions are needed.
structs like this?
typedef struct exp_ {
int val;
struct exp_ *child;
} *exp;
(This is straight from memory so it might not even compile.)
The use case is AST representation which makes heavy use of pointers to
structs (in fact IIRC it only uses pointers, never plain structs).
Right now I don't use typedefs since I read in the Linux kernel coding
guidelines that (the author believes) that it obfuscates what's really
going on. Note that pretty much every function in the compiler will
modify these structs so either the whole typedef will be in a .h file
or a bunch of access functions are needed.
Comment