VC ++ 2008中使用stdio.h编译错误

时间:2011-08-19 07:25:40

标签: c++ visual-studio-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

1 个答案:

答案 0 :(得分:7)

您的stdio.h文件已损坏。

第413行的令牌应该是_In_opt_,而不是_In_kpt_

第422行应该是#endif,而不是#efdif

我会重新安装VS 2008(如果你的硬盘发生故障或其他事情,请仔细检查一下)以防其他文件被巧妙地破坏。