Jump to content
  • Advertisement
Sign in to follow this  

A sintax error with a structure..

This topic is 4693 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've tried to used this class:
//Font informations
struct bn_FontInformations
    //Width of the font
    int iWidth;

    //Weight of the font
    int iWeight;

    //Height of the font
    int iHeight;

    //Specifies the character set for example: TURKISH_CHARSET;DEFAULT_CHARSET
    int iCharSet;

    //Specifies the pitch and family of the font FF_DECORATIVE;FF_DONTCARE;FF_MODERN
    int iPitchAndFamily;

    //Tests if it's italic
    bool bItalic;

    //The name of the font
    char *pFontName;


//Class for the font 
class bn_Font 
        //Initialise DirectXGraphics

        //Desturktor clears the class

        //Initialise DirectXGraphics
        void Initialise(LPDIRECT3DDEVICE9 lpD3DDevice,bn_FontInformations FontInfo);
        //Draws the Text
        void DrawText(char *pText,int iX,int iY,int iWidth = 0,int iHeight = 0, D3DCOLOR TextColor = D3DCOLOR_XRGB(0xFF,0xFF,0));

        //If the device'll be reseted
        void OnLostDevice();    

        //If the device has been reseted
        void OnResetDevice();


        //The font
        LPD3DXFONT m_lpD3DFont;

        //If it's initialised
        bool m_bInitialise;

inline void CopyPointingString(char *pTarget,char *pSource,int size)
    for(int i=0; i<size; i++)
        if (i == size-1)

//Initialise DirectXGraphics
    //Sets it 0
    m_lpD3DFont        = NULL;
    m_bInitialise    = false;

//If the device'll be reseted
void bn_Font::OnLostDevice()

//If the device has been reseted
void bn_Font::OnResetDevice()

//Initialise DirectXGraphics
void bn_Font::Initialise(LPDIRECT3DDEVICE9 lpD3DDevice,bn_FontInformations FontInfo)
    D3DXFONT_DESC FontDesc;
    if (FontInfo.pFontName)

    //Sets the informations
    FontDesc.Weight            = FontInfo.iWeight;
    FontDesc.Width             = FontInfo.iWidth;
    FontDesc.Height            = FontInfo.iHeight;
    FontDesc.CharSet           = FontInfo.iCharSet;
    FontDesc.PitchAndFamily    = FontInfo.iPitchAndFamily;
    FontDesc.Italic            = FontInfo.bItalic;
    FontDesc.MipLevels         = 1;

    //Creates the font

    m_bInitialise = true;
//Destructor clears the class
    if (NULL != m_lpD3DFont)
        m_lpD3DFont = NULL;

//Draws the Text
void bn_Font::DrawText(char *pText,int iX,int iY,int iWidth,int iHeight,D3DCOLOR TextColor)
    //Draws it
    if (m_bInitialise)
        //Creates a buffer
        char strBuffer[255];


        RECT r = {iX,iY,iWidth,iHeight};

        //Sets the size
        if (iWidth == 0 || iHeight == 0)

        //Gives it out

So i want use this class in my new class:
class bn_Font;
class Game

	bool init(HWND wndHandle, D3DXVECTOR3 posCamera);
	void shutdown(void);

	int update();
	void render(void);
	void fontManagerInit(void);
	void fontManagerDraw(void);


	LPDIRECT3DDEVICE9       pd3dDeviceGame;
	LPD3DXFONT				g_pd3dxFontGame;
	bool createGameObjects(void);
	// timer variables

	float         anim_rate;
	int squadra;
	int squadra2;

	int contDestra;
	int contSinistra;
	int contDietro;
	int contAvanti;

	int matrix[5][5];
	int n_1,j_1,n_2,j_2;

	char mamtfc;

	// Pointer to a CShip object
	CShip		  *pShip;						// the player's spaceship
	Personaggio2  *pPersonaggio2;
	GestioneTurni *pGestTurni;
	bn_Font		  *pFont;

	// Pointer to a CPlanet object
	CPlanet *pPlanet;					// The main planet

	// The game objects vector
	// This vector will store all the in-game objects to be updated and rendered
	std::vector <CGameObject*> objects;


bool Game::init(HWND wndHandle, D3DXVECTOR3 posCamera)

mamtfc = 'P';

	pFont->Initialise(g_pd3dxFontGame, 10, 10, 10, DEFAULT_CHARSET, FF_DONTCARE, FALSE, mamtfc);

	return true;
When i try to compile hit, i've this errors: error C2027: use of undefined type 'bn_Font' : see declaration of 'bn_Font' error C2227: left of '->Initialise' must point to class/struct/union I see that's a stupid errors for you, but i can't resolve this little problem. Anyone can help me? Thanks a lot.

Share this post

Link to post
Share on other sites
I'm moving this over to 'General Programming'. Whilst you're writing a DirectX program, it seems to me that your problem is just a general C/C++ issue rather than a DirectX specific one.

I personally don't have time to look through it in detail, but it seems you haven't specified which files those source fragments exist in. The error you descibe is typically one caused by messing up dependencies - e.g. failing to include the right file for example.

Maybe someone else will be able to shed some light on it [smile]


Share this post

Link to post
Share on other sites
The definition of class bn_Font must be "visible" at the point where you make use of such an object. Thus Game.cpp needs to #include "bn_font.h" (or whatever your actual file names are).

You should probably read this.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!