-1

我有这个 c++ 程序,由于某种原因它不会编译。我正在将 XP 与 VS 2005 一起使用。

#include "stdafx.h"
#include "MainThread.h"

HANDLE  hStopEvent = NULL;

int main(int argc, char *argv[])
{

    return 0;
}

error C2146: syntax error : missing ';' before identifier 'hStopEvent'
error C2377: 'HANDLE' : redefinition; typedef cannot be overloaded with any other symbol
see declaration of 'HANDLE'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
4

2 回答 2

5

该错误很可能是因为您在头文件中遇到了问题,这导致编译器将它在源文件中找到的第一件事视为标识符。

比如有一个未完成的结构或类定义:

struct blah {
    int a;
} // MISSING ';'

如果看不到,建议贴出头文件。

于 2012-12-26T21:40:57.137 回答
2

看起来你忘了

#include <Windows.h>
于 2012-12-26T21:30:16.473 回答