I get that problem as well.Personally I think it's a bug that has been with VS for a while now. Sometimes I can make changes in headers and every .cpp file that includes that header is recompiled as it should. After a while of using VS or for some random reason, this behavior stops and I have to choose Rebuild instead of Build.
Variable at construction not always updating
Re: Variable at construction not always updating
Curiosity killed the cat, satisfaction brought him back
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Variable at construction not always updating
Yeah, this is the main reason I like to use the CPP files, though I have been working on my SIMD and SIMD math library all in headers and so far only had that issue once.
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: Variable at construction not always updating
That problem just has to do with the compiler seeing changes from the standpoint of the source files. If any source file that includes the header file is able to see the changes in it, then it would be recompiled properly.
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat --
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat --
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Variable at construction not always updating
Right, that's what should happen, but it doesn't always happen that way is what we're saying.
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: Variable at construction not always updating
Thank you for that explanation. That clarified a lot. Actually it didn't work in release but did in debug. A implementation in the .cpp file worked.Florian3321 wrote:Hi there!
If I understand your problem, I think it happend due to that you only changed the values in the h file. If you then just build the project, because noting changed in the cpp file, the compiler does not make a new obj and does not link in a new exe, so the changes do not get into the game. If you rebuild, then the "new" h file gets it into the game, and the values are updated. On the one hand you can rebuild the solution or init the variable in the cpp file, not the h file. You can verify what I said if you compile your project, run it in the debugger and step into the constructor of game. If you get to the lines where the construction happens in the h file, Visual Studio tells you that the h file is different form the last build... I had the same problem and found that out, maybe it helps you:) What I do not unterstand is that it works if you build in release mode, maybe because VS rebuilds the project with optimizations?!
I did some work the last days and I am satisfied with my Invader clone. So thats my first game done
I realy learned a lot writing it! And I will take a leap of faith now and start a simple tower defence tomorrow. I think I will use SDL2 for that and hope that I am ready for that. If not I will do it with the ChiliFramework.
Anyway 1 done and so more to do
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Variable at construction not always updating
If you aren't fully commited to SDL2, I would suggest SFML. I found it easier to use and it's in C++ instead of C.
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: Variable at construction not always updating
Most discussions I read have a general sdl2>sfml mentality. I saw a good presentation for sdl2 on YouTube and with all the good comments about it I made the decision for it. But maybe it is worth to have a look at sfml too.albinopapa wrote:If you aren't fully commited to SDL2, I would suggest SFML. I found it easier to use and it's in C++ instead of C.
After I showed my space invaders to a friend I noticed that I forgot the ufo and I found a bug. So 1 extra day working on that one and then I'll start with the new.
Re: Variable at construction not always updating
So UFO is added bugs are fixed and my game is like I want it So I am finished with my first game
You can get the compiled Version here:
https://www.dropbox.com/s/auct23b0rofvo ... s.rar?dl=0
And here is my code:
https://github.com/Neithari/Space-Invaders
You can get the compiled Version here:
https://www.dropbox.com/s/auct23b0rofvo ... s.rar?dl=0
And here is my code:
https://github.com/Neithari/Space-Invaders
-
- Posts: 27
- Joined: February 12th, 2017, 1:50 pm
Re: Variable at construction not always updating
Congratulations! Looks really cool!