C syntax for functions returning function pointers

前端 未结 6 750
小蘑菇
小蘑菇 2020-12-02 04:49

Consider the following typedefs :

typedef int (*f1)(float);
typedef f1 (*f2)(double);
typedef f2 (*f3)(int);

f2 is a function

6条回答
  •  粉色の甜心
    2020-12-02 05:27

    Just don't. It can be done, but it will be very confusing. Typedef's are there to ease writing and reading this short of code.

    A function f that takes no arguments and returns a function pointer int (*)(float) would probably be something like (untested):

    int (*f())(float);
    

    Then for the rest you just need to keep adding parenthesis until it looks like lisp.

提交回复
热议问题