bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: declaring function pointers with explicit prototypes for the info re


From: Patrice Dumas
Subject: Re: declaring function pointers with explicit prototypes for the info reader
Date: Sun, 16 Jun 2024 17:47:44 +0200

On Sun, Jun 16, 2024 at 06:25:20PM +0300, Eli Zaretskii wrote:
> > Date: Sun, 16 Jun 2024 16:29:10 +0200
> > From: Patrice Dumas <pertusus@free.fr>
> > 
> > In standalone info reader code in info/ most function pointers are
> > declared as a generic function pointer VFunction *, defined in info.h as
> > 
> > typedef void VFunction ();
> > 
> > I think that it would be much better to use actual prototypes depending
> > on the functions to have type checking by the compiler.  I started doing
> > that and did not find any evident issue with having explicit prototypes,
> > but I may be missing something.
> > 
> > Would there be any reason not to have explicit prototypes?
> 
> If the code passes function pointers to other functions, or stores
> function pointers in arrays, the prototypes of the functions will have
> to match each other and/or the functions they are being passed to.  So
> beware when two functions of different signatures are placed into the
> same array or passed as an argument to the same function, because the
> compiler will at least emit a warning if not an error.

As far as I can tell, there are two cases in Info code.  Most of the
functions pointers are Info command functions and they all have the same
prototype, and are called at few places.  They are all in the
function_doc_array InfoCommand array.  The other case is functions in
terminal.c and terminal.h, which have diverse prototypes, but are not in
an array together and are called explictely.

-- 
Pat



reply via email to

[Prev in Thread] Current Thread [Next in Thread]