1. 程式人生 > >VS2003編譯OGRE error C2065: '__in' : undeclared identifier 解決

VS2003編譯OGRE error C2065: '__in' : undeclared identifier 解決

 

編譯所需要的東西

WinXP SP3 + MS VS 2003 + CMake 2.8 + Ogre 1.7.1 + Microsoft DirectX SDK (June 2010)+ OgreDependencies_MSVC_20100106.zip

編譯時出現:

------ Build started: Project: RenderSystem_Direct3D9, Configuration: Release Win32 ------

Compiling...
cl : Command line warning D4002 : ignoring unknown option '/fp:fast'
OgreD3D9VideoModeList.cpp
D:\Works\DX9_SDK\Include\DxErr.h(26) : error C2065: '__in' : undeclared identifier
D:\Works\DX9_SDK\Include\DxErr.h(26) : error C2146: syntax error : missing ')' before identifier 'HRESULT'
D:\Works\DX9_SDK\Include\DxErr.h(26) : warning C4229: anachronism used : modifiers on data are ignored
D:\Works\DX9_SDK\Include\DxErr.h(26) : error C2059: syntax error : ')'
D:\Works\DX9_SDK\Include\DxErr.h(27) : error C3861: '__in': identifier not found, even with argument-dependent lookup
D:\Works\DX9_SDK\Include\DxErr.h(27) : error C2146: syntax error : missing ')' before identifier 'HRESULT'
D:\Works\DX9_SDK\Include\DxErr.h(27) : warning C4229: anachronism used : modifiers on data are ignored
D:\Works\DX9_SDK\Include\DxErr.h(27) : error C2059: syntax error : ')'
D:\Works\DX9_SDK\Include\DxErr.h(46) : error C3861: '__in': identifier not found, even with argument-dependent lookup
D:\Works\DX9_SDK\Include\DxErr.h(46) : error C2146: syntax error : missing ')' before identifier 'HRESULT'
D:\Works\DX9_SDK\Include\DxErr.h(46) : warning C4229: anachronism used : modifiers on data are ignored
D:\Works\DX9_SDK\Include\DxErr.h(46) : error C2059: syntax error : ')'
D:\Works\DX9_SDK\Include\DxErr.h(47) : error C3861: '__in': identifier not found, even with argument-dependent lookup
D:\Works\DX9_SDK\Include\DxErr.h(47) : error C2146: syntax error : missing ')' before identifier 'HRESULT'
D:\Works\DX9_SDK\Include\DxErr.h(47) : warning C4229: anachronism used : modifiers on data are ignored
D:\Works\DX9_SDK\Include\DxErr.h(47) : error C2059: syntax error : ')'
D:\Works\DX9_SDK\Include\DxErr.h(71) : error C2065: '__in_z' : undeclared identifier
D:\Works\DX9_SDK\Include\DxErr.h(71) : error C2143: syntax error : missing ')' before 'const'
D:\Works\DX9_SDK\Include\DxErr.h(71) : warning C4229: anachronism used : modifiers on data are ignored
D:\Works\DX9_SDK\Include\DxErr.h(71) : error C2059: syntax error : ')'
D:\Works\DX9_SDK\Include\DxErr.h(72) : error C3861: '__in_z': identifier not found, even with argument-dependent lookup
D:\Works\DX9_SDK\Include\DxErr.h(72) : error C2143: syntax error : missing ')' before 'const'
D:\Works\DX9_SDK\Include\DxErr.h(72) : warning C4229: anachronism used : modifiers on data are ignored
D:\Works\DX9_SDK\Include\DxErr.h(72) : error C2059: syntax error : ')'
d:\Works\OgreSources_1.7.2\OgreMain\include\OgreTexture.h(433) : fatal error C1903: unable to recover from previous error(s); stopping compilation
...

===========解決方法===========

在DxErr.h自定義

#define __in
#define __in_z
#define __in_z_opt

然後編譯OK!

2,_wfindfirst不能將引數 1 從“const wchar_t *”轉換為“wchar_t *"錯誤

將if ((f = _wfindfirst((Utf8ToUtf16((dir_name + file_pattern).c_str()).c_str()), &fd)) != -1)修改成

if ((f = _wfindfirst((wchar_t*)(Utf8ToUtf16((dir_name + file_pattern).c_str()).c_str()), &fd)) != -1)