2011-08-19 131 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