下面的是错误信息(有源代码附上)各位帮忙看看啊,谢谢啊:
Creating command line "link.exe @C:\DOCUME~1\yang\LOCALS~1\Temp\RSPA4.tmp"
<h3>Output Window</h3>
Compiling...
transformation.cpp
c:\program files\microsoft directx sdk (march 2009)\include\d3dx9shader.h(955) : error C2146: syntax error : missing ';' before identifier 'HRESULT'
c:\program files\microsoft directx sdk (march 2009)\include\d3dx9shader.h(955) : error C2501: 'DECLSPEC_DEPRECATED' : missing storage-class or type specifiers
c:\program files\microsoft directx sdk (march 2009)\include\d3dx9shader.h(955) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.源代码:
//------------------------------------------------------------------------------------------
// File: Matrix.cpp
//
// Desc: render the 3D geometry use the 2D vertices.
//---------------------------------------------------------------------------
#include <windows.h>
#include <d3dx9.h>
#include <d3d9.h>
#include <mmsystem.h>//---------------------------------------------------------------------------
// Global variables
//---------------------------------------------------------------------------
LPDIRECT3D9 g_pD3D = NULL; // Used to create the D3DDevice
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; // Our rendering device
LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; // Buffer to hold vertices// A structure for our custom vertex type 
struct CUSTOMVERTEX
{
FLOAT x, y, z;
DWORD color;
};// Our custom FVF.
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)//---------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//---------------------------------------------------------------------------
bool InitD3D( HWND hWnd )
{
// Create the D3D object.
if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
return false; // Set up the structure used to create the D3DDevice
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof( d3dpp ) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; // Create the D3DDevice
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice ) ) )
{
return false;
} // Turn off culling ,so we see the front and back of the triangle 
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );

//Turn off D3D lighting ,since we are providing our own vertex colors
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); return true;
}
//--------------------------------------------------------------------------
// Name: InitGeometry()
// Desc: Create the scene geometry
//---------------------------------------------------------------------------
bool InitGeometry()
{
// Initialize three vertices for rendering a triangle
CUSTOMVERTEX g_Vertices[] = 
{
{-1.0f, -1.0f, 0.0f, 0xffff0000, },
{ 1.0f, -1.0f, 0.0f, 0xff0000ff, },
{ 0.0f,  1.0f, 0.0f, 0xffffffff, },
}; // Create the vertex buffer.
if( FAILED( g_pd3dDevice->CreateVertexBuffer( 3*sizeof( CUSTOMVERTEX ),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &g_pVB,
NULL ) ) )
{
return false;
}

// Fill the vertex buffer.
VOID* pVertices;
if( FAILED( g_pVB->Lock( 0, sizeof( g_Vertices ), (void**)&pVertices, 0 ) ) )
return false;
memcpy( pVertices, g_Vertices, sizeof( g_Vertices ) );
g_pVB->Unlock(); return true;
}
//--------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all initialized objects
//---------------------------------------------------------------------------
VOID Cleanup()
{
if( g_pVB != NULL )
g_pVB->Release();
if( g_pd3dDevice != NULL )
g_pd3dDevice->Release();
if( g_pD3D != NULL )
g_pD3D->Release();
}//---------------------------------------------------------------------------
// Name: SetupMatrices()
// Desc: sets up the word, view, and projection transform Matrices.
//---------------------------------------------------------------------------
VOID SetupMatrices()
{
// For our world matrix.
D3DXMATRIXA16 matWorld;
UINT iTime = timeGetTime() % 1000;
FLOAT fAngle = iTime * ( 2.0f * D3DX_PI ) / 1000.0f;
D3DXMatrixRotationY( &matWorld, fAngle );
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); // Set our view matrix.
D3DXVECTOR3 vEyePt( 0.0f, 3.0f, -5.0f );
D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
D3DXMATRIXA16 matView;
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
g_p3dDevice->SetTransform( D3DTS_VIEW, &matView );

// Set our Projection matrix.
D3DXMATRIXA16 matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI / 4, 1.0f, 1.0f, 100.0f);
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
}
//---------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//---------------------------------------------------------------------------
VOID Render()
{
// Clear the backbuffer to a black color
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 0 ), 1.0f, 0 );

// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Setup the world, view, and projection Matrices
SetupMatrices(); // Render the vertex buffer contents
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 );

// End the scene
g_pd3dDevice->Endscene();
} // Present the backbuffer to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
LRESULT CALLBACK MsgProc( HWND hWnd,UINT msg,WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
Cleanup();
PostQuitMessage(0);
return 0;
case WM_PAINT:
Render();
ValidateRect( hWnd, NULL );
return 0;
}
return DefWindowProc(hWnd,msg,wParam,lParam);
}
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
WNDCLASSEX wndclass;
HWND hwnd; wndclass.cbClsExtra = 0;
wndclass.cbSize = sizeof(WNDCLASSEX);
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wndclass.cbWndExtra = 0;
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon = LoadIcon(hInstance,"directx.ico");
wndclass.hIconSm = NULL;
wndclass.hInstance = hInstance;
wndclass.lpfnWndProc = (WNDPROC)MsgProc;
wndclass.lpszClassName = "stance";
wndclass.lpszMenuName = NULL;
wndclass.style = CS_HREDRAW|CS_VREDRAW;
RegisterClassEx( &wndclass ); hwnd = CreateWindow("stance","yang",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,,hInstance,NULL);
if(!hwnd){
return false;
}if( SUCCEEDED( InitD3D( hWnd ) ) )
    {
        // Create the vertex buffer
        if( SUCCEEDED( InitGeometry() ) )
        {
            // Show the window
            ShowWindow( hwnd, SW_SHOWDEFAULT );
            UpdateWindow( hwnd );            // Enter the message loop
            MSG msg;
            ZeroMemory( &msg, sizeof( msg ) );
            while( msg.message != WM_QUIT )
            {
                if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
                {
                    TranslateMessage( &msg );
                    DispatchMessage( &msg );
                }
                else
                    Render();
            }
        }
    }
return 0;
}我不知道到底哪里出错了,从提示上看是我的SDK出问题了。我只要一包含d3dx9.h这个头文件就报错。单独编译这个头文件还是提示同样的错误。我不知道到底是我的代码有问题还是SDK出错了。望各位高手帮忙看看。