[問題] 指標指到NULL的問題

看板Programming作者 (終於自由了)時間14年前 (2010/06/23 13:01), 編輯推噓0(008)
留言8則, 3人參與, 最新討論串1/1
我現在正在整合一份code 有個struct 如下 typedef struct i2c_feusb_t { void* handle ; i2c_listener_t* pListener ; void* user ; } i2c_feusb_t ; func_result_t drvi2c_feusb_Read (i2c_t * pI2c, uint8_t deviceAddress, uint8_t * pData, uint32_t size, uint8_t mode) { int result = 0 ; i2c_feusb_t* feusb = NULL ; .... } 每次只要跑到 = NULL那行就出現error error訊息是can not convert i2c_feusb_t to void 這個錯誤訊息有什麼含意嗎..? 請問該怎麼解決呢 上面的code是用C寫的 我要整合到一個.NET的project去 在COM object的一個member function需要執行上面的function 卡了好久 試過把NULL 改成 (void*)0 結果還是一樣.. 拜託版上高手給我點建議 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 66.75.28.157 ※ 編輯: littlehau 來自: 66.75.28.157 (06/23 13:02)

06/23 13:09, , 1F
他的意思是說不能 implicit cast
06/23 13:09, 1F

06/23 13:09, , 2F
試試 = (i2c_feusb_t*) NULL;
06/23 13:09, 2F

06/23 19:38, , 3F
有什麼原因一定要指到 NULL 嗎 ?
06/23 19:38, 3F

06/23 22:21, , 4F
原PO不見了。猜想他可能只是要設個初值吧
06/23 22:21, 4F

06/23 22:49, , 5F
對,只是想設個初值,function的後面
06/23 22:49, 5F

06/23 22:49, , 6F
會指到driver的handler
06/23 22:49, 6F

06/24 15:42, , 7F
謝謝各位的回答,問題解決了
06/24 15:42, 7F

06/24 15:42, , 8F
方法如同一樓所說,太感謝了
06/24 15:42, 8F
文章代碼(AID): #1C8PK-D7 (Programming)