0
我創建了一個簡單的代碼:STAT()在MinGW的工作錯誤
int main(int argc, char *argv[])
{
struct stat eStat;
int result;
struct stat eStat2;
int result2;
result = stat("g:/temp/dvd", &eStat);
printf("result=%d | eStat.st_mode=%d | S_IFMT=%d | S_IFDIR=%d\n",result,eStat.st_mode,S_IFMT,S_IFDIR);
if((eStat.st_mode & S_IFMT) == S_IFDIR)
printf("It is a dir!!!\n");
else
printf("not a dir\n");
result2 = stat("g:\\temp\\test.txt", &eStat2);
printf("test.txt result2=%d | eStat2.st_mode=%d | S_IFMT=%d | S_IFDIR=%d\n",result2,eStat2.st_mode,S_IFMT,S_IFDIR);
return 0;
}
我在VS2010(Windows7, C++)
編譯此代碼,輸出:
result=0 | eStat.st_mode=16895 | S_IFMT=61440 | S_IFDIR=16384
It is a dir!!!
test.txt result2=0 | eStat2.st_mode=33206 | S_IFMT=61440 | S_IFDIR=16384
我Linux(Debian stable, gcc)
編譯此代碼,輸出:
result=0 | eStat.st_mode=16877 | S_IFMT=61440 | S_IFDIR=16384
It is a dir!!!
test.txt result2=0 | eStat2.st_mode=33188 | S_IFMT=61440 | S_IFDIR=16384
當我在mingw(gcc) on Windows7
編譯時,輸出:
result=0 | eStat.st_mode=6 | S_IFMT=61440 | S_IFDIR=16384
not a dir
test.txt result2=0 | eStat2.st_mode=6 | S_IFMT=61440 | S_IFDIR=16384
爲什麼st_mode
始終顯示6,當我在mingw
編譯?
對於使用mingw的Dev C++,適合我。什麼是編譯器版本?你在使用任何IDE嗎? – 2012-04-10 09:53:43
我使用cmake 2.8.7版和mingw gcc-core-4.6.1-2進行編譯。你可以用mingw gcc編譯嗎?我沒有使用IDE。我嘗試在Windows上編譯genisoimage。 – 2012-04-10 10:03:04
我從[這裏](http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/)下載了mingw,它對我來說完全正常 – 2012-04-10 10:19:12