[Buildroot] Analysis results for 2018-10-09

Baruch Siach baruch at tkos.co.il
Thu Oct 11 11:45:16 UTC 2018


Hi Peter,

Peter Korsgaard writes:
>>>>>> "Baruch" == Baruch Siach <baruch at tkos.co.il> writes:
>  >> -typedef double hbase_f(double);
>  >> +typedef double (*hbase_f)(double);
>
>  > Wouldn't that make the definition 'hbase_f *val_in' a pointer to
>  > function pointer?
>
> Not in C at least. The syntax is:
>
> typedef <returntype> (*name)(<arguments>)
>
> https://stackoverflow.com/questions/1591361/understanding-typedefs-for-function-pointers-in-c

Correct. But consider the SO example code:

  typedef void (*SignalHandler)(int signum);

  extern SignalHandler signal(int signum, SignalHandler handler);

The 'handler' parameter of the signal() function is a pointer to a
function. However the definition

  SignalHandler *handler;

would create a pointer to a pointer. As I understand, this is not the
intention of the 'hbase_f *val_in' definition in the original code.

baruch

--
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


More information about the buildroot mailing list