I'm taking a look at some stuff I wrote back in 2001 or so, and it no longer compiles. A quick search was not so helpful. I wasn't an expert to begin with, and haven't looked at C++ in the 11 years since, so I'm feeling like a beginner making beginner mistakes. This used to make under KDevelop, which I no longer use, but it uses autotools, so I was hoping this would still make.
I'm now using
c++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
Here are a couple of things that seem to have changed.
- I originally had stuff on the line after #endif, intended to help me match #ifs with the #endif. This now causes a compiler error.
- I used "or" as an identifier, and I'm getting syntax errors on the line where it's declared.
- cerr and endl seem to need declarations; whatever I had there before no longer does the job.
SO: have things really changed that much? Where do I look?
- I originally had stuff on the line after #endif, intended to help me match #ifs with the #endif. This now causes a compiler error.
Put the "stuff" in comments maybe?
- I used "or" as an identifier, and I'm getting syntax errors on the line where it's declared.
or is a keyword so you cannot use it as an identifier.
- cerr and endl seem to need declarations; whatever I had there before no longer does the job.
Did you include <iostream>? Everything in the standard library is inside the std namespace so write std::cout and std::endl or use the using directive.
I could figure out the quick fixes myself. What I'd like to know, for instance, is where to find out what the new keyword "or" does, and what others became keywords along with it.
I'd like to know about versions of C++ and where I can bring myself up to date.
And, yes, I included <iostream>. I'm having trouble verifying that I did so *everywhere*. I need to shut off the thousands of warnings about deprecated constructs, so I can see the errors. Maybe you can help with that too.
The newest "version"(specification) of C++ is C++11. It is till not supported completely in compilers, but many compilers now support the most important things in C++11. The "or" operator is an alternative to || . Here is a list of the keywords: http://en.cppreference.com/w/cpp/keyword .
I could figure out the quick fixes myself. What I'd like to know, for instance, is where to find out what the new keyword "or" does, and what others became keywords along with it.
The only thing that changed is that compilers are enforcing the C++ standard more strictly, but your program was already incorrect back then. So as long as you stick to the rules, you shouldn't have trouble compiling your programs in a few years. The (nearly) current "rules" can be found here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf
Thanks. That's actually a relief. I had visions of a culture of all sorts of forward incompatibilities. Presuming that g++ has just gotten more strict but the rules haven't actually changed, I won't mind spending the time to fix these things up.
I'm not sure I'm going to read much of that 1K+ page working draft, though.
I have only Stroustrup's book, really, and I found the reference to "or" in it tucked away in the back. I never read all of that, either. So long as I'm asymptotically approaching compliance to a stationary target, I'll be okay. This is just a retired programmer's hobby anyway.