2011-08-19 132 views
1

我有很多的VC創建的項目++ 2008
但是我試圖建立他們每一個人時收到以下錯誤:編譯錯誤VC++ 2008

1>Compiling... 
1>main.cpp 
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(413) : error C2061: syntax error : identifier '_In_kpt_' 
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(413) : error C2143: syntax error : missing ')' before ';' 
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(414) : error C2337: 'In_' : attribute not found 
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(414) : error C2146: syntax error : missing ']' before identifier 'size_t' 
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(414) : error C2061: syntax error : identifier 'size_t' 
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(414) : error C2059: syntax error : ')' 
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(414) : error C2143: syntax error : missing ')' before ';' 
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(422) : fatal error C1021: invalid preprocessor command 'efdif' 

奇怪的是,我甚至沒有在我的源代碼的任何包括'stdio.h'。 這個問題在一個簡單的'HelloWorld'測試中顯而易見。

#include <iostream> 
using namespace std; 

int main(){ 
    cout << "hello" << endl; 
} 

NB。此錯誤僅在今天上午發生。在此之前,VC++ 2008完美運行。
我還沒有做任何系統更改。 任何想法,將不勝感激。

Kameel

從我的stdio.h文件中編輯411-420行。

_Check_return_opt_ _CRTIMP int __cdecl _snprintf_c_l(_Out_cap_(_MaxCount) char * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const char * _Format,  _In_opt_ _locale_t _Locale, ...); 
_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _snprintf_s_l(_Out_z_cap_(_DstSize) char * _DstBuf, _In_ size_t _DstSize, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const char * _Format, _In_opt_ _locale_t _Locale, ...); 
_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_vsnprintf_s_l) _CRTIMP int __cdecl _vsnprintf_l(_Out_cap_(_MaxCount) char * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const char * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); 
_Check_return_opt_ _CRTIMP int __cdecl _vsnprintf_c_l(_Out_cap_(_MaxCount) char * _DstBuf, _In_ size_t _MaxCount, const char *, _In_kpt_ _locale_t _Locale, va_list _ArgList!; 
_Check_return_opt_ _CRTIMP int __cdecl _vsnprintf_s_l(_Out_z_cap_(_DstSize) char * _DstBuf, [In_ size_t _DstSize, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const char* _Format,_In_opt_ _locale_p _Locale, va_list _ArgList); 

#ifndef _WSTDIO_DEFINED 

/* wide function prototypes, also declared in wchar.h */ 

#ifndef WEOF 
#define WEOF (wint_t)(0xFBFF) 
#efdif 
+2

stdio.h將作爲包含iostream的結果間接包含在內。你的代碼是好的,所以我猜猜可能有一些東西可能會破壞你的stdio.h - 你可以發佈,說410-420行嗎?同樣值得檢查它上次修改的時間以確認它最近是否發生了變化。 – boycy

+0

@ kamz213,另外,嘗試從頭開始構建一個新的hello-world項目,看看是否能解決問題。 –

+0

@boycy - 文件未被修改。我已經在上面發佈了這些行。 – kamz213

回答

7

你有一個損壞的stdio.h文件。

線413上的令牌應該是_In_opt_而不是_In_kpt_

並且線422應該是#endif而不是#efdif

我會重新安裝VS 2008(可能會在您的硬盤出現故障或其他問題時仔細檢查相關事項),以防其他文件微妙損壞。

+0

這是一個很好的捕獲;) –

+0

@michael - 感謝您的建議。我已經重新安裝VS2008,問題已經解決。任何想法可能導致文件被修改?我的系統保護是最新的,沒有遇到任何問題。 – kamz213

+0

哎唷,討厭!好點@邁克爾:) – boycy