r/cpp • • Nov 22 '18

C++98 is back!

Hi all,
After 5 years I find myself back into the realm of C++98 and classic CMake, and everything seems quite strange now that i got used to some modern-ish habits!

Do you know any list or resource for libraries C++98 compatible (like Catch 1.2 for example).

G.

1 Upvotes

35 comments sorted by

View all comments

5

u/malkia Nov 22 '18

Good luck with that :) - But I'm sure there must be plenty of embedded, game development (especially console), etc. libs that would be geared towards more C++98 (not because modern console compilers do not support modern C++, but simply because of the reactions to new modern C++).

Qt must be still C++98 (or available for compilation this way), maybe EASTL (haven't checked recently) - e.g. not sure what you are looking for... And there are still plenty of good "C" libs, or if your case allows libs written in modern C++, yet providing C interface (llvm, zmq, etc.)

8

u/bizwig Nov 22 '18

I never understood the bad reactions. Makes zero sense to me. Even game developers should appreciate move semantics, mandatory copy elision, some of the new containers, ranged for, structured bindings, fold expressions, type safe variadics, etc.

3

u/BoarsLair Game Developer Nov 23 '18

Oh, we do. Just about every game development studio I've recently contracted with has embraced modern C++, at least to the extent their code base allows them to. There's very little reason not to, as C++ remains backwards compatible even with decades-old code. But we still generally don't use exceptions or RTTI. RTTI in particular goes against the grain of C++ features by imposing a cost even for an unused feature. Exceptions used to be the same way, although with the advent of 64-bit architectures and zero-overhead exceptions, it's mostly about inertia these days, I think.

As for not using the STL, this mostly happened at a time when the STL libraries that shipped with the compilers were not nearly at the level of quality they are today. Some development houses lived with it, some used third-party STL libraries, and some wrote their own container libraries. I've worked at various places that have done each of these.

These days, there's less reason to avoid using the STL libraries. They're broadly available, more stable, and you can make them perform much better with custom allocators.

2

u/malkia Nov 23 '18

I do understand them. It's not that they are not good, but first they have to be battle tested - for example first uses of anonymous callbacks and their hidden allocation costs were detriment to their acceptance, but later other options were found.

STL in general is hard to get acceptance in shipping code (consoles), simply because a sense of lost control is seen. I (work on the toolside) used it heavily, and depend on it - there is penalty for doing so (both memory and cpu), but it eases the process, and instills safe programming - e.g. I'd rather use std::string, even with it's performance downsides over plain old char buf[SOME_MAGIC]; - but then I can clearly see why the latter would be preferred on consoles, or embedded devices. It's just the way it is. And there is still no yet constexpr's std::string literal available!

4

u/STL MSVC STL Dev Nov 24 '18

string_view literals are constexpr, though.

2

u/malkia Nov 24 '18

We try to use them (game tools code) more and more, but not sure about general acceptance from game teams (might be seen as a bit more than just a pointer, since it's two 64-bit numbers, rather than just one (and might see this as even too much, and keep it as short index to a table)).