[neomutt-devel] Uniformize structures storing operations

Damien Riegel damien.riegel at gmail.com
Wed Feb 15 18:12:23 CET 2017

On Wed, Feb 15, 2017 at 04:56:14PM +0000, Pietro Cerutti wrote:
> On 2017-Feb-15, 11:41, Damien Riegel wrote:
> > 2. Typedef'ing function pointers
> > 
> > I agree that it improves readability when a function pointer is passed
> > as an argument to another function. Example from Stack Overflow [2]:
> > 
> >   extern void (*signal(int, void(*)(int)))(int);
> > vs.
> >   typedef void (*SignalHandler)(int signum);
> >   extern  SignalHandler signal(int signum, SignalHandler handler);
> > 
> > But for `ops` stored in a structure like in the three examples above it
> > doesn't make much difference, it only adds one level of indirection
> > when reading the code. Moreover in the coding style discussion, it seems
> > we generally want to avoid typedefs (except in a few cases). So does it
> > also apply here?
> Speaking for hcache, I decided to typedef the types of the functions
> used as operations in order to provide proper documentation for them.
> So, for function pointers typedefs are fine to me.

I don't get it, there doesn't seem to be a limitation here. If I take
FFmpeg as exemple, it seems perfectly fine to embed this comment within
the struct definition:


More information about the neomutt-devel mailing list