Advertisement

Would it be acceptable if I programmed a game for XP, Vista, 7, and 8 to spare for Windows 10? Are these Windows versions still widely used today?

Started by July 10, 2018 06:56 PM
30 comments, last by rjhwinner03 6 years, 2 months ago

These are really essential debug skills. 

When you get your crash when running in debug mode double click on the entry in the call stack window where it says game.exe!APPLICATION::Update. VS will set the cursor to the line that was called before entering std::vector code. 

Copy the code there and the lines above and paste them here. It sounds like you're using an iterator of one vector with a function of a different vector.

 

Regarding old versions: Something must be off in your project when you can't get it to compile. I suspect the book author set some weird configurations. You can compile for XP with VS 2015 fine (even with DX8 or DX9), if you keep to the older APIs.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

4 hours ago, rjhwinner03 said:

I cant... I get Windows SDK errors when I try to build, forcing me to stick with VS 2008.

You are going about this in a really bad way.  When you get errors you should understand and then fix them.  You should NOT try to ignore and get around them by any means possible.  

Here's what you have to do:

1. Get your current code compiling and get to a good stopping point.

2. Get the latest version of Visual Studio Community, which is free, and convert your solution/projects to that.

3. When you get errors or whatever problems, solve them.  If you dont know how to, ask here or search other sites.  The problems you're having have almost certainly been faced and solved by many before you.

4. Continue with your project.

You should also familiarize yourself with basic debugging techniques such as the call stack and everything else that VS gives you (watch windows, breakpoints, data breakpoints, etc.  It will make your life easier and these are basic things that a programmer needs to know.

To answer the other question about whether you should target different, older, windows versions... the answer is no.  Right now Windows 7 and Windows 10 together have something like 85% market share among Windows.  So I would target Windows 7 as my minimum and definitely forget ones like Windows XP.  There's few reasons to target such an old OS, and "I dont want to fix Visual Studio configuration issues" is not one of them.

Advertisement

Ok... I am led to this for loop

 

        std::vector<EFFECT*>::iterator i;

        for(i=effects.begin();i != effects.end();)
        {
            if((*i)->isDead())
            {
                delete (*i);
                effects.erase(i);
            }
            else 
            {
                (*i)->Update(deltaTime * m_gameSpeed);
                i++;
            }
        }

I see the problem. As I suspected, it's the way you're erasing the thing from a vector: std::vector::erase invalidates the iterator you pass into it. If you try to iterate from the iterator, you'll get undefined behavior. Very common mistake, I've seen even seasoned professionals screw that one up. Mostly because they're not overly familiar with the standard library - which in modern code is a mistake in and of itself. :)

The quickest way to solve the problem is to assign the result of erase() to i, since std::vector::erase returns a new (valid) iterator on completion, but in modern C++, you would write this quite differently, and in such a way that this wouldn't be a problem...


effects.erase(std::remove_if(
  std::begin(effects),
  std::end(effects),
  [](const EFFECT* effect) {
    return effect->isDead();
  }),
  std::end(effects));

for (EFFECT* effect : effects)
{
  effect->Update(deltaTime * m_gameSpeed);
}                

In general, you should a) make liberal use of the standard algorithms b) use a compiler that supports at least C++'11 so that you can use them without loads and loads of boilerplate. In modern C++ you want to avoid working directly with iterators.

Thanks!

I am used to using the vector::erase function for just individual variables instead of iterators because they were used in VS '03...

 

Example

effects.erase(&effectVariable);

Windows 7 is still very popular. Many people use it, and it is still very very active in gaming-support.
Anything before 7 is dead and fruitless. Don't

Advertisement
18 hours ago, rjhwinner03 said:

I am just more familiar with Visual C++ 6, Visual Studio 2003(I am most comfortable with this one because I started out with it), and Watcom C/C++..

1

As a developer, one of the key skills you need to cultivate is the ability to learn new tools. C++ as a language has moved on in the last 15 years. Visual Studio 2003 is just about standards compliant with C++03 but VC++ 6 is a garbage fire. The tooling was ok for its time, but the compiler is awful. Seriously, I cannot encourage you strongly enough to drop it.

18 hours ago, rjhwinner03 said:

@ChaosEngine, how much experience do you have?

 

enough that I remember upgrading from Visual Studio 97 to Visual C++ 6.

 

18 hours ago, rjhwinner03 said:

if you can just tell me what to do so I can get back to work, that would also be appreciated...

If you saw someone building a house on a crumbling cliffside, would you tell them to move the house or help them paint it?

 

if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

Wow! You guys were right! Using new technology IS cool! Everything works now because I got it working in VS 2017!!! 

 

Thanks!!!

Thanks to everyone on this forum!

Welcome to the 20th century!

Omae Wa Mou Shindeiru

You mean the 21st century?

 

I wish it was the 20th century... my code might actually work...

This topic is closed to new replies.

Advertisement