[問題] 關於Callback範例的問題?

看板C_and_CPP (C/C++)作者 (oeoe)時間16年前 (2009/04/28 18:49), 編輯推噓2(202)
留言4則, 3人參與, 最新討論串1/1
請教各位~ 我參考這網頁範例 http://www.newty.de/fpt/callback.html#chapter3 7 void qsort(void* field, size_t nElements, size_t sizeOfAnElement, 8 int(_USERENTRY *cmpFunc)(const void*, const void*)); 9 10 void qsort(void* field, size_t nElements, size_t sizeOfAnElement, 11 int(_USERENTRY *cmpFunc)(const void*, const void*)) 12 { 13 int bigger=cmpFunc(item1, item2); 14 } 但是出現錯誤 main.c:8: error: syntax error before '*' token main.c:8: error: syntax error before ')' token main.c:11: error: syntax error before '*' token main.c:11: error: syntax error before ')' token 因為對Callback不熟,實在不知道怎麼解決這問題,麻煩前輩指點!感謝~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.220.139.2

04/28 20:00, , 1F
_USERENTRY,是不是應該改成int之類的型態?
04/28 20:00, 1F

04/28 20:05, , 2F
_USERENTRY可能是要定義為某一個call conv.
04/28 20:05, 2F

04/28 20:05, , 3F
不過他既然說是callback了 就用__stdcall吧
04/28 20:05, 3F

04/29 09:49, , 4F
改int更多錯,改成__stdcall還是錯一樣!忘了說我是用gcc..
04/29 09:49, 4F
文章代碼(AID): #19zjzLNj (C_and_CPP)
文章代碼(AID): #19zjzLNj (C_and_CPP)