2012-12-26 26 views
-1

我有這個C++程序,並由於某種原因它不會編譯。我在VS 2005中使用XP。C++錯誤typedef不能超載

#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 
+0

問題將出現在您的標題中。 – JasonD

回答

4

該錯誤是最有可能是因爲你有在頭文件中的問題,這導致編譯器處理髮現的第一件事情源文件作爲標識符。

喜歡的東西有一個未完成的結構或類定義:

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

如果你不能看到它,我建議張貼的頭文件。

+0

或者在「MainThread.h」中有問題 –

+0

是的,你是對的......這是重新定義的東西,扔了我,但你可以得到它,沒有明確地重新定義它...... – JasonD

2

看起來你忘了

#include <Windows.h> 
+0

它已經在裏面stdafx.h –