我通常會搜索此錯誤。但是在VS C++ Express中,這個錯誤會出現在你做的每一個錯誤上。任何我如何收到以下錯誤C2146:語法錯誤:缺少';'之前標識符'頂點'
error C2146: syntax error : missing ';' before identifier 'vertices'
每次這個錯誤我添加以下代碼在我的文檔
// Create vertex buffer
SimpleVertex vertices[] =
{
D3DXVECTOR3(0.0f, 0.5f, 0.5f),
D3DXVECTOR3(0.5f, -0.5f, 0.5f),
D3DXVECTOR3(-0.5f, -0.5f, 0.5f),
};
的頂部下方是它的全部代碼。不能弄清楚什麼是錯的。感謝
[編輯]
// include the basic windows header file
#include "D3Dapp.h"
class MyGame: public D3Dapp
{
public:
bool Init3d();
};
MyGame game;
struct SimpleVertex
{
D3DXVECTOR3 Pos; // Position
};
// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
game.InitWindow(hInstance , nCmdShow);
return game.Run();
}
bool MyGame::Init3d()
{
D3Dapp::Init3d();
// Create vertex buffer
SimpleVertex vertices[] =
{
D3DXVECTOR3(0.0f, 0.5f, 0.5f),
D3DXVECTOR3(0.5f, -0.5f, 0.5f),
D3DXVECTOR3(-0.5f, -0.5f, 0.5f),
}
return true;
}
新的錯誤
1>c:\users\numerical25\desktop\intro todirectx\msdntutorials\tutorial0\tutorial\tutorial\main.cpp(14) : error C2146: syntax error : missing ';' before identifier 'Pos'
'D3Dapp.h'中定義了'SimpleVertex'類嗎? – 2010-04-24 21:46:21
不,不是,SimpleVertex的第一個外觀就是你現在看到的地方。 – numerical25 2010-04-24 21:51:43
我編輯了代碼。見頂部 – numerical25 2010-04-24 21:55:49