Since at least C++11 we got lovely fixed width integers for example in C++'s <cstdint>
or in C's <stdint.h>
out of the box, (for example std::uint32_t
, std::int8_t
), so with or without the std::
in front of them and even as macros for minimum widths (INT16_C
, UINT32_C
and so on).
Yet we have do deal with libraries every day, that define their own fixed width integers and you might have seen for example sf::Int32
, quint32
, boost::uint32_t
, Ogre::uint32
, ImS32
, ... I can go on and on if you want me to. You too know a couple more probably.
Sometimes these typedefs (also often macro definitions) may lead to conflicts for example when you want to pass a std
fixed width integer to a function from a library expecting a fixed width integer with exactly the same width, but defined differently.
The point of fixed width integers is them having a fixed size, which is what we need in many situations as you know. So why would all these libraries go about and typedef exactly the same integers we already have in the C++ standard? Those extra defines are sometimes confusing, redundant and may invade your codebase, which are very bad things. And if they don't have the width and signedness they promise to have, they at least sin against the principle of least astonishment, so what's their point I hereby ask you?