new cpp file = circular dependency
new cpp file = circular dependency
Why adding cpp file to GameStateLogin.h cause me circular dependency ?
no includes nothing just make new cpp file for GameStateLogin.h and i got 70 errors
no includes nothing just make new cpp file for GameStateLogin.h and i got 70 errors
- Attachments
-
- Game.rar
- (1.13 MiB) Downloaded 144 times
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: new cpp file = circular dependency
There were no errors when I built and ran it. Try going to the Menu / Build / Rebuild and see if the problem is still there.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: new cpp file = circular dependency
did u made GameStateLogin.cpp ? cuz i upload without it https://s27.postimg.org/bez9ukoo3/Untitled_1.jpg
and without him its ok everything works
and without him its ok everything works
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: new cpp file = circular dependency
No, figured you would have kept it in there for testing. Let me try it and see.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: new cpp file = circular dependency
Ok, so here's the problem: Adding #include "ChiliWin.h" in a header file or any other header that includes the ChiliWin.h file will probably keep causing you issues.
How I resolved the issue was moving the include to the CPP file, and adding #define FULL_WINTARD before any of the includes.
You might be able to get away with adding the #define FULL_WINTARD in the header before the rest of the includes, but I didn't try it.
How I resolved the issue was moving the include to the CPP file, and adding #define FULL_WINTARD before any of the includes.
You might be able to get away with adding the #define FULL_WINTARD in the header before the rest of the includes, but I didn't try it.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: new cpp file = circular dependency
Example:
GameStateLogin.cpp
GameStateLogin.cpp
Code: Select all
#define FULL_WINTARD
#include "../Game.h"
#include "GameStateLogin.h"
GameStateLogin::GameStateLogin( Game * gm )
:
GameStateFirstPhase( gm )
{}
void GameStateLogin::Draw( Graphics & gfx )
{}
void GameStateLogin::Update()
{}
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: new cpp file = circular dependency
You could add a header file with just the following lines, and include it instead of having to type the two lines in every CPP file
ChiliWintard.h
Just remember to include this file before any others.
Also, it's going to depend on where the file resides, here I put the ChiliWintard.h file in Engine, instead of the Framework folder.
ChiliWintard.h
Code: Select all
#pragma once
#define FULL_WINTARD
#include "Framework\ChiliWin.h"
Also, it's going to depend on where the file resides, here I put the ChiliWintard.h file in Engine, instead of the Framework folder.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: new cpp file = circular dependency
By the way, do you realize you are leaking memory when you change states?
You should probably either make pCurrentState a unique_ptr, or be deleting your current state before assigning the new state.
Code: Select all
void Game::SetGameState(GameState* newstate)
{
pCurrentState = newstate;
}
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: new cpp file = circular dependency
Game.h
Game.cpp
then for the different game states when changing states:
Code: Select all
#include <memory>
void SetGameState(std::unique_ptr<GameState> &&newstate);
std::unique_ptr<GameState> pCurrentState;
Code: Select all
void Game::SetGameState( std::unique_ptr<GameState>&& newstate )
{
pCurrentState = std::move( newstate );
}
Code: Select all
pGame->SetGameState(std::make_unique<GameStateSelectServer>(pGame));
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: new cpp file = circular dependency
ChiliWintard.h
i have to include this into each of header and cpp file or only into each of cpp files?
And as far as i know i need to delete only when i call it with a new ? or i am wrong ?
i have to include this into each of header and cpp file or only into each of cpp files?
And as far as i know i need to delete only when i call it with a new ? or i am wrong ?