簡體   English   中英

在C語言中,在pthread_create中使用函數名稱時是否與使用引用相同?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM