VS2010 & DirectX11 SDK & Windows SDK 编程过程中的 错误/异常/解决方案 记录

ID3DBlob 未声明的标记符 undefined signal

ID3DBlob 定义在 D3DCommon.h 中, 但是 使用 vs2010 & DirectX11 联合开发时, D3DCommon.h 会有两份, 如我的环境是:

C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\D3DCommon.h
D:\Program Files\Microsoft DirectX SDK (June 2010)\Include\D3Dcommon.h

这样, 即使 在项目中有 包含 d3dx11.h (包含 D3DCommon.h) 也不能正确进行 编译, 需要将 DirectX11 sdk 包含目录 在 Windonws sdk 的前面, 如:

 

D3DCOMPILE_ENABLE_STRICTNESS 未声明标记符

D3DX11CompileFromFile() 创建 加载并编译 shader文件时 需要用到 的 shaderFlags , 定义在 D3DCompiler.h 中, 需要 include

 

xnamath.h 报错: 在标识符“XMConvertToRadians”的前面

如下报错:

1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C2146: 语法错误: 缺少“;”(在标识符“XMConvertToRadians”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C2433: “FLOAT”: 不允许在数据声明中使用“__forceinline”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C2146: 语法错误: 缺少“)”(在标识符“fDegrees”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C2059: 语法错误:“)”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2146: 语法错误: 缺少“;”(在标识符“XMConvertToDegrees”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2433: “FLOAT”: 不允许在数据声明中使用“__forceinline”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2086: “int FLOAT”: 重定义
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159) : 参见“FLOAT”的声明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2146: 语法错误: 缺少“)”(在标识符“fRadians”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2059: 语法错误:“)”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(217): error C2146: 语法错误: 缺少“;”(在标识符“__vector4i”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(217): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(217): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(246): error C2146: 语法错误: 缺少“;”(在标识符“i”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(246): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(246): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(260): error C2146: 语法错误: 缺少“;”(在标识符“u”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(260): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(260): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(316): error C2061: 语法错误: 标识符“FLOAT”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(316): error C2805: 二进制“operator *=”的参数太少
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(317): error C2061: 语法错误: 标识符“FLOAT”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(317): error C2805: 二进制“operator /=”的参数太少
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(323): error C2061: 语法错误: 标识符“FLOAT”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(324): error C2146: 语法错误: 缺少“)”(在标识符“S”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(324): error C2365: “operator *”: 重定义;以前的定义是“函数”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(324): error C2440: “初始化”: 无法从“int”转换为“XMVECTOR”
1> 无构造函数可以接受源类型,或构造函数重载决策不明确
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(324): error C2059: 语法错误:“)”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(325): error C2061: 语法错误: 标识符“FLOAT”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(325): error C2805: 二进制“operator /”的参数太少
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(342): error C2146: 语法错误: 缺少“;”(在标识符“_11”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(342): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(342): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(342): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(342): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(342): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(343): error C2146: 语法错误: 缺少“;”(在标识符“_21”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(343): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(343): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(343): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(343): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(343): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(344): error C2146: 语法错误: 缺少“;”(在标识符“_31”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(344): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(344): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(344): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(344): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(344): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(345): error C2146: 语法错误: 缺少“;”(在标识符“_41”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(345): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(345): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(345): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(345): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(345): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(347): error C2146: 语法错误: 缺少“;”(在标识符“m”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(347): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(347): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(354): error C2061: 语法错误: 标识符“FLOAT”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(354): error C2535: “_XMMATRIX::_XMMATRIX(void)”: 已经定义或声明成员函数
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(352) : 参见“_XMMATRIX::_XMMATRIX”的声明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(358): error C2061: 语法错误: 标识符“CONST”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(358): error C2535: “_XMMATRIX::_XMMATRIX(void)”: 已经定义或声明成员函数
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(352) : 参见“_XMMATRIX::_XMMATRIX”的声明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(360): error C2143: 语法错误 : 缺少“;”(在“(”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(360): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(360): error C3646: “CONST”: 未知重写说明符
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(360): error C2719: “Row”: 具有 __declspec(align('16')) 的形参将不被对齐
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(360): error C2719: “Column”: 具有 __declspec(align('16')) 的形参将不被对齐
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(360): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(361): error C2143: 语法错误 : 缺少“;”(在“&”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(361): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(361): error C2719: “Row”: 具有 __declspec(align('16')) 的形参将不被对齐
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(361): error C2719: “Column”: 具有 __declspec(align('16')) 的形参将不被对齐
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(361): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(361): error C2556: “int &_XMMATRIX::operator ()(UINT,UINT)”: 重载函数与“int _XMMATRIX::operator ()(UINT,UINT)”只是在返回类型上不同
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(360) : 参见“_XMMATRIX::operator ()”的声明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(361): error C2040: “_XMMATRIX::operator ()”:“int &(UINT,UINT)”与“int (UINT,UINT)”的间接寻址级别不同
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(361): error C2059: 语法错误:“return”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(361): error C2238: 意外的标记位于“;”之前
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(363): error C2143: 语法错误 : 缺少“;”(在“&”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(363): error C2065: “CONST”: 未声明的标识符
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(363): error C2146: 语法错误: 缺少“)”(在标识符“_XMMATRIX”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(363): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(363): error C2059: 语法错误:“)”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(366): error C2065: “CONST”: 未声明的标识符
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(366): error C2146: 语法错误: 缺少“)”(在标识符“_XMMATRIX”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(366): error C2365: “operator *=”: 重定义;以前的定义是“函数”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(366): error C2059: 语法错误:“)”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(367): error C2065: “CONST”: 未声明的标识符
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(367): error C2146: 语法错误: 缺少“)”(在标识符“_XMMATRIX”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(367): error C2365: “operator *”: 重定义;以前的定义是“函数”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(367): error C2059: 语法错误:“)”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(372): error C2059: 语法错误:“}”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(372): error C2143: 语法错误 : 缺少“;”(在“}”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(372): error C2059: 语法错误:“}”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(378): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(378): error C2143: 语法错误 : 缺少“;”(在“&”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(378): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(378): error C2530: “CXMMATRIX”: 必须初始化引用
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(386): error C2146: 语法错误: 缺少“;”(在标识符“HALF”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(386): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(386): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(391): error C2146: 语法错误: 缺少“;”(在标识符“x”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(391): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(391): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(392): error C2146: 语法错误: 缺少“;”(在标识符“y”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(392): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(392): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(397): error C2061: 语法错误: 标识符“FLOAT”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(397): error C2535: “_XMFLOAT2::_XMFLOAT2(void)”: 已经定义或声明成员函数
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(396) : 参见“_XMFLOAT2::_XMFLOAT2”的声明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(398): error C2061: 语法错误: 标识符“CONST”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(398): error C2535: “_XMFLOAT2::_XMFLOAT2(void)”: 已经定义或声明成员函数
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(396) : 参见“_XMFLOAT2::_XMFLOAT2”的声明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(400): error C2061: 语法错误: 标识符“CONST”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(400): error C2805: 二进制“operator =”的参数太少
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(397): error C2065: “_x”: 未声明的标识符
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(397): error C2065: “_y”: 未声明的标识符
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(397): error C2614: “_XMFLOAT2”: 非法的成员初始化:“y”不是基或成员
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(397): error C2614: “_XMFLOAT2”: 非法的成员初始化:“x”不是基或成员
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(411): error C2061: 语法错误: 标识符“FLOAT”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(411): error C2535: “XMFLOAT2A::XMFLOAT2A(void)”: 已经定义或声明成员函数
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(410) : 参见“XMFLOAT2A::XMFLOAT2A”的声明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(412): error C2061: 语法错误: 标识符“CONST”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(412): error C2535: “XMFLOAT2A::XMFLOAT2A(void)”: 已经定义或声明成员函数
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(410) : 参见“XMFLOAT2A::XMFLOAT2A”的声明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(414): error C2061: 语法错误: 标识符“CONST”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(414): error C2805: 二进制“operator =”的参数太少
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(411): error C2065: “_x”: 未声明的标识符
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(411): error C2065: “_y”: 未声明的标识符
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(412): error C2065: “pArray”: 未声明的标识符
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(423): error C2146: 语法错误: 缺少“;”(在标识符“x”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(423): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(423): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(424): error C2146: 语法错误: 缺少“;”(在标识符“y”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(424): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(424): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(429): error C2061: 语法错误: 标识符“HALF”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(429): error C2535: “_XMHALF2::_XMHALF2(void)”: 已经定义或声明成员函数
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(428) : 参见“_XMHALF2::_XMHALF2”的声明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(430): error C2061: 语法错误: 标识符“CONST”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(430): error C2535: “_XMHALF2::_XMHALF2(void)”: 已经定义或声明成员函数
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(428) : 参见“_XMHALF2::_XMHALF2”的声明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(431): error C2061: 语法错误: 标识符“FLOAT”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(431): error C2535: “_XMHALF2::_XMHALF2(void)”: 已经定义或声明成员函数
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(428) : 参见“_XMHALF2::_XMHALF2”的声明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(432): error C2061: 语法错误: 标识符“CONST”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(432): error C2535: “_XMHALF2::_XMHALF2(void)”: 已经定义或声明成员函数
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(428) : 参见“_XMHALF2::_XMHALF2”的声明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(434): error C2061: 语法错误: 标识符“CONST”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(434): error C2805: 二进制“operator =”的参数太少
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(429): error C2065: “_x”: 未声明的标识符
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(429): error C2065: “_y”: 未声明的标识符
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(429): error C2614: “_XMHALF2”: 非法的成员初始化:“y”不是基或成员
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(429): fatal error C1003: 错误计数超过 100;正在停止编译

将 #include <xnamath.h>头文件放到 

#include <D3D11.h>
#include <d3dx11.h>
#include <DxErr.h>
#include <D3DCompiler.h> // for shader flags

的后面

 

d:\program files\microsoft directx sdk (june 2010)\include\dxerr.h(26): error C2146: 语法错误: 缺少“;”(在标识符“DXGetErrorStringA”的前面)

还是头文件包含问题, 在 cpp 文件里使用了 DXTRACE_MSG() 宏( which 最终应该使用到 DXGetErrorStringA() 宏), cpp 只包含的头文件 .h 只包含了 DxErr.h , DxErr.h 的相关宏及其他设置需要 整个 D3D11的预设值, 否则无法得到正确配置, 需要在 DxErr.h 包含前包含 D3D11.h 和 D3DX11.h ( 我不知道具体需要包含哪个, 干脆直接包含这两个). 解决该问题的过程记录:

1.使用 vs2010 开发, 编译错误时, 一般只查看 "vs2010 > 错误列表", 并双击查看最终错误报告:

但这样是不能直接找到的问题所在的, 尝试了如下思路:

1. vs2010 中设置 本项目的 "VC++目录" 中, D3D相关 Include 目录没有设置到 合理的优先位置: "包含目录", "库目录", "链接器"的 "附加依赖项" 内 D3D 相关的走在最前面, 并且至少包含了 d3d11.h, d3dx11.h 和 dxerr.h 

2.除了 dxerr.h 的报错外, 还有 winnt.h  winbase.h 的相关问题, 怀疑是不是 #include<windows.h>  和 #include <dxerr.h> 的问题:

即便调整 顺序后, 还是不行.

3. 百度 > google > 全英文搜索, 呃, 没有 找到.

以上这种查找 方式, 是因为 此前遇到过相似的 这些包含问题, 只要设置对就行了. 但这次不行. 

4. DxGetErrorStringA() 报错, 肯定是因为什么地方 使用到了 dxerr.h 的头文件包含, 确定到 某个文件 使用了 DXTRACE_MSG() 调用( 因为当前项目只使用了 dxerr 的 该宏), 但有很多文件 使用了 DXTRACE_MSG() 到底是哪个? 如果能够在 linux 使用 g++ 的makefile 能够看到整个编译详细过程就好了, 在那里能够具体看到 是在 编译文件是出错. 啊哈, 找到了 "vs2010 > 输出" :

 

问题得以定位. 有两点总结:

1. 开发 D3D11 时, 如果使用 dxerr.h 就应该尽量 包含 d3d11.h 和 d3dx11.h

2. 查找问题, 要确定好是在 编译哪个 文件时出错.

 

Draw() 出错:

D3D11: WARNING: ID3D11DeviceContext::Draw: Input vertex slot 0 has stride 16 which is less than the minimum stride logically expected from the current Input Layout (20 bytes). This is OK, as hardware is perfectly capable of reading overlapping data. However the developer probably did not intend to make use of this behavior. [ EXECUTION WARNING #355: DEVICE_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL ]
D3D11: WARNING: ID3D11DeviceContext::Draw: Vertex Buffer at the input vertex slot 0 is not big enough for what the Draw*() call expects to traverse. This is OK, as reading off the end of the Buffer is defined to return 0. However the developer probably did not intend to make use of this behavior. [ EXECUTION WARNING #356: DEVICE_DRAW_VERTEX_BUFFER_TOO_SMALL ]

情况一是, 图形完全没有任何东西渲染出来, 一个原因是 没有设置好 vertex 数据  和  纹理对应数据.

情况二是, "WARNING" 仅仅是警告而已, 一个原因正如其描述的, 我传递的 stride 大小为16 小于 最小预期值, 原来代码顶点描述为:

    struct VertexPos{
        XMFLOAT2 pos;
        XMFLOAT2 tex;
    };

sizeof( VertexPos) 就为 16, 改为 

    struct VertexPos{
        XMFLOAT3 pos;
        XMFLOAT2 tex;
    };

后, 即可消除 WARNING, 第三位不用的话默认设置成 1.0f 

 

“AF_IPX”: 宏重定义

Windows.H与WINSOCK2.H的包含关系,包含顺序改为 
#include <winsock2.h>
#include<windows.h>
即可. 如果还不行的话, 可采用 http://www.zachburlingame.com/2011/05/resolving-redefinition-errors-betwen-ws2def-h-and-winsock-h/ 的方法, 闯将最顶层的头文件:
#ifndef _WINSOCK_WRAPPER_H_
#define _WINSOCK_WRAPPER_H_

#if _MSC_VER > 1000
#pragma once
#endif

#ifndef _WINDOWS_
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#endif

#include <winsock2.h>

#pragma comment(lib, "ws2_32.lib")

#endif

 



 

模板 与 extern“C” 问题

在添加一个 c 实现的文件 到 cpp 项目时,出现如下报错:

1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2061: 语法错误: 标识符“acosf”
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2059: 语法错误:“;”
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2061: 语法错误: 标识符“asinf”
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2059: 语法错误:“;”
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2061: 语法错误: 标识符“atanf”
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2059: 语法错误:“;”
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2061: 语法错误: 标识符“atan2f”
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2059: 语法错误:“;” 

听说一种解决方式是, 将 .c 文件修改为 .cpp

确实修改过后问题得以解决, 但出现新的问题:

1>d:\program files\microsoft visual studio 10.0\vc\include\xstddef(78): error C2894: 模板不能声明为有“C”链接
1>d:\program files\microsoft visual studio 10.0\vc\include\xstddef(87): error C2894: 模板不能声明为有“C”链接
1>d:\program files\microsoft visual studio 10.0\vc\include\xstddef(132): error C2894: 模板不能声明为有“C”链接
1>d:\program files\microsoft visual studio 10.0\vc\include\xstddef(141): error C2894: 模板不能声明为有“C”链接

这是因为在文件最开始位置使用了 extern “C”, 并在 evllib.h 使用了大量的模板

#ifdef __cplusplus
extern "C" {
#endif

#include <stdlib.h>
#include <EvlLib/evllib.h>

将模板相关的 头文件移动到 extern “C” 前面即可。

posted @ 2013-01-20 12:51  Wilson-Loo  阅读(8353)  评论(0编辑  收藏  举报