Hi Marc,

> Many if not the majority of Gnulib modules provide typedefs for the
> public structs they export (*). It just occurred to me that the
> (x)string-buffer module does not provide any typedef for its struct
> string_buffer.
> 
> Was this an oversight or on purpose?

What would be the benefit?

typedefs are usually used to hide implementation details, for example
'u64' may be a struct or an integer type. Or, some libraries define
  typedef struct foo foo_t[1];
when they want a type that is not copied when passed through a function
call.

When the API contains a struct type, the programmer knows exactly what
happens in function calls and whether to pass a pointer.

The only benefit that I see is that the typedef name is usually shorter
to write. But that does not matter when, typically, there will be 1 or
at most 2 instances of such a struct in a given function.

Bruno




Reply via email to