[英]Where is the code for dirent.h (opendir, readdir, closedir)? Undefined symbol
我正在使用Tiny C編譯器編譯一些使用dirent.h的C代碼(只是試圖列出目錄的內容)當我編譯時,我得到這些錯誤:
tcc: error: undefined symbol 'opendir'
tcc: error: undefined symbol 'readdir'
tcc: error: undefined symbol 'closedir'
當我打開dirent.h時,這里有3個函數頭:
DIR* __cdecl opendir (const char*);
struct dirent* __cdecl readdir (DIR*);
int __cdecl closedir (DIR*);
這可能聽起來很愚蠢,但這些函數頭的實際代碼在哪里? 在我看來,這就是它不能編譯的原因。
編譯器如何只用標題編譯而不編譯.c代碼?
謝謝。
顯然readdir,opendir,closedir是UNIX函數,在Windows上不可用。
更新:我發現一些移植到Windows的C代碼可以工作。 見鏈接:
http://www.two-sdg.demon.co.uk/curbralan/code/dirent/dirent.html
http://www.two-sdg.demon.co.uk/curbralan/code/dirent/dirent.c
http://www.two-sdg.demon.co.uk/curbralan/code/dirent/dirent.h
停止使用古老的編譯器。
只需使用GCC(MinGW-w64)或MSVC。 你需要剛剛在MinGW-w64 GCC中實現的POSIX功能,所以你就是這樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.