int main(int argc, char* argv[])
{
char str[256];
FILE *fp = NULL;
int h[3];
SDL_TimerID playtimer, fpstimer;
if (!init())
return 1;
if (argc>1) {
if (!strcmp(argv[1],"-l") && (argc==3)) {
mode = PLAY;
if (!viewer->open(argv[2])) {
error("Unable to load data file\n");
exit(1);
}
} else if (!strcmp(argv[1], "-w") && (argc==3)) {
mode = SIMULATE;
fp = fopen(argv[2], "wb");
fwrite(h, sizeof(int), 3, fp);
} else {
printf("Invalid command line argument. Usage: fluid [-l|-w <filename>]\n");
exit(1);
}
} else {
mode = SIMULATE;
}
if (mode == SIMULATE)
simthread = SDL_CreateThread(simulate, NULL);
if (mode == PLAY)
playtimer = SDL_AddTimer(1000/16, timer_proc, NULL);
fpstimer = SDL_AddTimer(1000, showfps, NULL);
EventLoop(fp);
SDL_RemoveTimer(fpstimer);
if (mode==PLAY)
SDL_RemoveTimer(playtimer);
if (mode == SIMULATE) {
quitting = true;
SDL_WaitThread(simthread, NULL);
}
if (fp && (mode == SIMULATE)) {
int pos;
h[0] = h[1] = N+2;
h[2] = simframes;
pos = ftell(fp);
fseek(fp, 0, SEEK_SET);
fwrite(h, sizeof(int), 3, fp);
fclose(fp);
printf("%d frames written to file %s, %d kiB\n", simframes, argv[2], pos>>10);
}
请问您能帮我解决这个问题吗?提前致谢。可能未初始化的本地指针变量'playtimer'used
以上是我的代码显示。错误和警告都低于:
警告C4101: 'STR':未引用的局部变量 -
警告C4715: 'SDL_main':不是所有的控制路径返回一个值 -
错误C4703:潜在的未初始化本地指针变量 “playtimer”使用
请学习格式化代码。对于任何人来看代码非常重要。另外,我还没有纠正像缺少main的右括号这样的语法错误。 – Mahesh
对不起,因为这是我的第一个问题。 – asdfg
“mode”声明在哪里? – AnT