作者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