作者oeoe7788 (oeoe)
看板C_and_CPP
標題[問題] 關於Callback範例的問題?
時間Tue Apr 28 18:49:56 2009
請教各位~
我參考這網頁範例
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
1F:推 jlovet:_USERENTRY,是不是應該改成int之類的型態? 04/28 20:00
2F:推 sunneo:_USERENTRY可能是要定義為某一個call conv. 04/28 20:05
3F:→ sunneo:不過他既然說是callback了 就用__stdcall吧 04/28 20:05
4F:→ oeoe7788:改int更多錯,改成__stdcall還是錯一樣!忘了說我是用gcc.. 04/29 09:49