News for hackers. Stuff that matters.
Re:A Special Kind of Hell: intmax_t in C and C++ by PaulDavisThe1st on Saturday December 05, 2020 @05:52PM (#25319205)
I don't use int64_t and expect it to exist. I use int64_t and expect compilation to fail if stdint.h doesn't define it. It would be a problem, but much less of a problem than using intWhatever_t, having compilation work, but having no idea what the bounds were.

intmax_t doesn't define an upper limit either, as TFA explains, because you don't know at runtime what the limit really is.

Re:A Special Kind of Hell: intmax_t in C and C++ by josefx on Sunday December 06, 2020 @04:00AM (#25322174)
> but having no idea what the bounds were.

The idea for the library writer are that the bounds are large enough for whatever the user needs. User inputs a int64_t? Great the type intmax_t on that system is at least int64_t wide by definition. System doesn't have a int64_t ? Great the user can at best use a int32_t, which intmax_t would once again support.

> intmax_t doesn't define an upper limit either, as TFA explains

Yeah, it would almost be sad that C++ is getting bitten by Cs lack of name mangling. Almost because it is kinda pointless to define a maximum integer in a language where any programmer can add their own fixed sized integer types, so a generic library supporting arbitrary sized integers would have to take template parameters anyway.