在看AMCL源码时,发现typedef的用法看不懂,搜了下,发现是函数指针的重命名
// Function prototype for the initialization model; generates a sample pose from // an appropriate distribution. typedef pf_vector_t (*pf_init_model_fn_t) (void *init_data); // Function prototype for the action model; generates a sample pose from // an appropriate distribution typedef void (*pf_action_model_fn_t) (void *action_data, struct _pf_sample_set_t* set); // Function prototype for the sensor model; determines the probability // for the given set of sample poses. typedef double (*pf_sensor_model_fn_t) (void *sensor_data, struct _pf_sample_set_t* set);
先看第一个,pf_init_model_fn_t是声明的新名字,也可以这么写
typedef pf_vector_t (*) (void *init_data) pf_init_model_fn_t;
这样看就清晰了。
typedef void (*) (void *action_data, struct _pf_sample_set_t* set) pf_action_model_fn_t;
pf_action_model_fn_t是函数指针,指向带两个参数的函数,函数无返回类型。
第三个同样的理解
还有其他的复杂声明的,可以看https://www.cnblogs.com/wen-ge/articles/5807509.html
原文:https://www.cnblogs.com/havain/p/15009833.html