私は gcc に取り組んでいますが、これが可能かどうか疑問に思っています:
関数 (NOTmain ではなく aLocalFn) があり、その中でローカル変数を宣言しています。次に、このローカル引数をスレッド引数として渡します。それは実行可能ですか?または、threadFunction が実行される前に aLocalVar が失われ、参照 idxPtr が無意味を指している可能性があります (最初に実行される内容によって異なります)。
int *threadFunction(void *idxPtr){
int rec_idx=(int) *idxPtr;
//work in the thread with this variabel rec_idx
}
int aLocalFn(){
int aLocalVar=returnsRecordIndex();
pthread_create(&thread_id,&attr_detached,threadFunction, &aLocalVar)!=0)
return 0;
}
ご協力ありがとうございました