[問題] 想請問一下struct list_head這個結構要怎麼include

看板C_and_CPP (C/C++)作者 (衝衝衝)時間15年前 (2011/03/06 23:31), 編輯推噓3(3010)
留言13則, 5人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Unix GCC、 Windows XP DEV-C++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 各位前輩好, 小弟最近要撰寫一個程式,是屬於雙向Linked list的, 想使用struct list_head來撰寫, 我用DEV-C++或Unix的GCC來Compiler,都不給我過, 感覺是我沒include到正確的library, 小弟google了半小時,只有教學文章,沒有提到include的問題, 所以最後只能來這樣求助各位前輩, 謝謝大家 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) #include <stdio.h> #include <stdlib.h> struct student { struct list_head list; int age; char name[30]; int score; }; int main() { printf("hello\n"); return 0; } 補充說明(Supplement): compiler就錯了,顯示: program.cpp:5: error: field ‘list’ has incomplete type 真的很抱歉,完全沒深度的問題, 但是煩腦我一陣子了, 謝謝各位前輩。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.170.153.133

03/06 23:34, , 1F
您的 struct list_head 宣告在哪邊?
03/06 23:34, 1F

03/06 23:35, , 2F
Windows 不能用吧
03/06 23:35, 2F

03/06 23:35, , 3F
回一樓:小弟在上面有附程式碼,謝謝大哥!
03/06 23:35, 3F

03/06 23:36, , 4F
回二樓大哥,小弟用UNIX的GCC跑,也是一樣的錯誤訊息
03/06 23:36, 4F

03/06 23:36, , 5F
歹勢啊,真的太沒深度了,我問得很慚愧.....
03/06 23:36, 5F

03/06 23:37, , 6F
我怎麼記得那個是 Linux Kernel 裡的東西...?
03/06 23:37, 6F

03/06 23:39, , 7F
GCC 可以跟 Unix 劃等號嗎?
03/06 23:39, 7F

03/06 23:44, , 8F
原來是linux提供的 我查到的是說在 <linux/list.h> @@
03/06 23:44, 8F

03/06 23:46, , 9F
感覺文中講到的都是在 kernel source code 裡面
03/06 23:46, 9F

03/06 23:47, , 10F
struct list_head 定義在這 : http://ppt.cc/F65S
03/06 23:47, 10F

03/06 23:48, , 11F
相關的操作函式在這 http://ppt.cc/;1Zs
03/06 23:48, 11F

03/06 23:48, , 12F
感謝各位前輩,小弟去取經一下
03/06 23:48, 12F

03/07 13:57, , 13F
XD
03/07 13:57, 13F
文章代碼(AID): #1DSwZRw4 (C_and_CPP)
文章代碼(AID): #1DSwZRw4 (C_and_CPP)