[問題] 在structure裡面宣告的問題

看板C_and_CPP作者 (eojdkf)時間13年前 (2012/05/01 09:27), 編輯推噓6(607)
留言13則, 6人參與, 最新討論串1/2 (看更多)
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) NotPad++ 問題(Question): 如題,Debug這段很久了,還是看不出哪裡有出錯, compiler是說前兩行出錯了, 我猜是指標(*)出錯了, 請各位幫我看看, 謝謝!! 錯誤結果(Wrong Output): 錯誤:expected 「)」 before 「*」 token 錯誤:expected 「;」 before 「s8int」 程式碼(Code):(請善用置底文網頁, 記得排版) s8int (*init ) (device_t* dev); s8int (*close) (device_t* dev); s8int (*open) (device_t* dev, u16int open_flag); u32int (*read) (device_t* dev, u32int pos, u32int size, void* buffer); u32int (*write) (device_t* dev, u32int pos, u32int size, const void* buffer); s8int (*ctrl) (device_t* dev, u8int cmd, void *args); 置底文網頁: http://ideone.com/3cShy -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 134.208.2.150 ※ 編輯: sean823823 來自: 134.208.2.150 (05/01 17:30)

05/01 17:50, , 1F
你有 typedef xxx s8int; 這樣嗎?
05/01 17:50, 1F

05/01 18:39, , 2F
有耶!!
05/01 18:39, 2F

05/01 18:40, , 3F
我已經定義過了!!
05/01 18:40, 3F

05/01 21:47, , 4F
搞不好錯在這段code的前面?
05/01 21:47, 4F

05/02 13:36, , 5F
我檢查N變了
05/02 13:36, 5F

05/02 13:37, , 6F
所以這段語法是沒有錯的?!
05/02 13:37, 6F

05/02 16:31, , 7F
用個置底空間貼全部程式碼上來吧 光這樣似乎很難抓錯
05/02 16:31, 7F
※ 編輯: sean823823 來自: 134.208.2.150 (05/03 19:06) ※ 編輯: sean823823 來自: 134.208.2.150 (05/03 19:07)

05/03 20:18, , 8F

05/03 21:01, , 9F
原來.. 出在 typedef struct / struct.
05/03 21:01, 9F

05/04 00:05, , 10F
喔不~ 主要問題應該是出在讀到107行時,還不曉得device_t
05/04 00:05, 10F

05/04 00:06, , 11F
使用向前宣告: http://ideone.com/EZytT
05/04 00:06, 11F

05/04 00:07, , 12F
PS: 相對於原Po增加在93, 94行
05/04 00:07, 12F

05/04 13:48, , 13F
感謝!!
05/04 13:48, 13F
文章代碼(AID): #1FdwoAqX (C_and_CPP)
文章代碼(AID): #1FdwoAqX (C_and_CPP)