【发布时间】:2009-08-09 12:20:59
【问题描述】:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
static struct tm createDate(unsigned day, unsigned mon, int year) {
struct tm b = {0,0,0,day,mon-1,year-1900}; return b;
}
static int dateExceeded(unsigned day, unsigned mon, int year) {
struct tm b = createDate(day,mon,year);
time_t y = mktime(&b), now;
time(&now); // error C2143: syntax error : missing ';' before 'type'
double diff = difftime(y, now) / (60 * 60 * 24); // error C2065: 'diff' : undeclared identifier
return (diff < 0);
}
static void randomEvent(){
srand(time(NULL));
if ( rand()%10) {
printf("Do something here\n"); // C2143: syntax error : missing ';' before 'type'
}
}
【问题讨论】:
-
@Matthew:很可能,尤其是因为它在 GCC 下编译得很好。
-
@Zed:是的,这是一个隐含的
unsigned int。例如,这有点像如何将long int声明为long。 -
@htw,添加 --std=c90 -pedantic-errors 你也会遇到 gcc 错误。