Search code examples
visual-c++structc89

error C2275: illegal use of this type as an expression


Error is thrown at second line:

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;

I'm working in VC++, Visual Studio 2012. There were similar posts about variable declaration problem for c89, but I can't get this code working.


Solution

  • The problem is that you didn't define a variable name for the D3DLIGHT9 pointer in your function declaration. You just need to do this:

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