爲什麼在Ubuntu中構建這個程序時會產生語法錯誤?time_t st_mtime行的語法錯誤?
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "time.h"
#include "sys/types.h"
#include "sys/stat.h"
int main()
{
time_t st_mtime;
printf("Hello\n");
return 0;
}
這裏就是我得到的,當我試圖建立這樣的:
$ gcc -o test1 test1.c
test1.c: In function ?main?:
test1.c:10: error: expected ?=?, ?,?, ?;?, ?asm? or ?__attribute__? before ?.? token
test1.c:10: error: expected expression before ?.? token
檢查預處理器輸出:
$ gcc -E test1.c > test1.d
顯示行10:
time_t st_mtim.tv_sec;
的只有當我包含「sys/stat」時纔會出現錯誤.h「&」time.h「文件。
'「'只對本地文件。這些應該是'#包括',等等。 –
Dave
2012-01-03 14:40:26
st_mtime可能是一個預處理宏象'#定義st_mtime time_array [XXXX]'。和名字的前綴是' st_'有一個原因... – wildplasser 2012-01-03 14:44:51