4
在以下代碼行中,dup_func,free_func和clear_free func前的星號是幹什麼的?函數名稱前的星號是什麼意思?
void *(*dup_func)(void *);
void (*free_func)(void *);
void (*clear_free_func)(void *);
在以下代碼行中,dup_func,free_func和clear_free func前的星號是幹什麼的?函數名稱前的星號是什麼意思?
void *(*dup_func)(void *);
void (*free_func)(void *);
void (*clear_free_func)(void *);
在您的示例中,這意味着它們是function pointers。
簡而言之,它們允許你做這樣的事情:
void example()
{
printf("Example called!\n");
}
void call_my_function(void (*fun)())
{
printf("Calling some function\n");
(*fun)();
}
/* Later. */
call_my_function(example);
請注意,空括號是舊式(K&R C),由C99廢棄。你應該在無效的地方加上'void'。 – Jens
什麼語言?我猜C,但誰知道。 – aroth
這裏是第一個意思是:[cdecl](http://cdecl.ridiculousfish.com/?q=void+*%28*dup_func%29%28void+*%29%3B) –
[void(* a)(char *,char *);這是一個函數?](http://stackoverflow.com/questions/5546867/void-achar-char-is-this-a-function) – outis