错误C2275:非法使用此类型作为表达式

时间:2013-11-27 02:08:48

标签: visual-c++ struct c89

第二行引发错误:

HRESULT Direct3DDevice9Wrapper::GetLight(DWORD Index, D3DLIGHT9 *)
{
     return Direct3DDevice9->GetLight(Index, D3DLIGHT9);
}

D3DLIGHT9 deffinition:

typedef struct _D3DLIGHT9 
{
     D3DLIGHTTYPE    Type;            /* Type of light source */
     D3DCOLORVALUE   Diffuse;         /* Diffuse color of light */
     D3DCOLORVALUE   Specular;        /* Specular color of light */
     D3DCOLORVALUE   Ambient;         /* Ambient color of light */
     D3DVECTOR       Position;         /* Position in world space */
     D3DVECTOR       Direction;        /* Direction in world space */
     float           Range;            /* Cutoff range */
     float           Falloff;          /* Falloff */
     float           Attenuation0;     /* Constant attenuation */
     float           Attenuation1;     /* Linear attenuation */
     float           Attenuation2;     /* Quadratic attenuation */
     float           Theta;            /* Inner angle of spotlight cone */
     float           Phi;              /* Outer angle of spotlight cone */
} D3DLIGHT9;

我在VC ++,Visual Studio 2012中工作。有关c89的变量声明问题的类似帖子,但我无法使这段代码正常工作。

1 个答案:

答案 0 :(得分:2)

问题是您没有在函数声明中为D3DLIGHT9指针定义变量名。你只需要这样做:

HRESULT Direct3DDevice9Wrapper::GetLight(DWORD Index, D3DLIGHT9 *pLight)
{
     return Direct3DDevice9->GetLight(Index, pLight);
}