Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error C2146: syntax error : missing ';' before identifier 'vertices' [closed]

Tags:

c++

directx

I would usually search for this error. But in VS C++ Express, this error comes up for just about every mistake you do. Any how I recieve this error below

error C2146: syntax error : missing ';' before identifier 'vertices'

everytime I add the following code at the top of my document

// 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 ),
};

below is the code in it's entirety. Cant figure out whats wrong. thanks

[EDIT]

// 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;
}

new error

1>c:\users\numerical25\desktop\intro todirectx\msdntutorials\tutorial0\tutorial\tutorial\main.cpp(14) : error C2146: syntax error : missing ';' before identifier 'Pos'
like image 247
numerical25 Avatar asked Apr 24 '10 21:04

numerical25


1 Answers

error C2146: syntax error : missing ';' before identifier 'vertices'

Usually this error occurs when what's before the identifier isn't known to the compiler. In your case that means the compiler hasn't seen SimpleVertex yet.

like image 115
sbi Avatar answered Sep 18 '22 15:09

sbi