[英]In C, when using the name of the function in pthread_create is it the same as using a reference?
我不確定我說的是否正確。
pthread_create(..., ..., &some, ...);
...is the same as:
pthread_create(..., ..., some, ...);
我正在學習線程,如果您可以提供一個非常簡單的網站或視頻,那就太好了。 線程-鎖,條件變量等。謝謝!
是的,因為函數名稱指向存儲位置 。 簡單來說,它是一個內存地址,因此您像foo
或&foo
一樣傳遞它,它們是相同的。
示例代碼:
#include <stdio.h>
int foo(){
printf("hello world");
}
int (*fuu)();
int main (void)
{
fuu = foo;
fuu();
return 0;
}
希望這可以幫助
您可以使用函數名稱some
或指向函數&some
指針來獲取函數的地址。
還要檢查這個答案 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.