News for hackers. Stuff that matters.
Re:C's Flexible Integer Sizes Were Not a Design Mistake by astrobe_ on Sunday September 27, 2026 @05:51AM (#49865121)
Is that really that much of a big deal, though? Before stdint, if one needed that level of accuracy, one would do your own equivalent of stdinit by hand, and adjust those definitions when porting to another compiler/platform. The same goes for your local boolean type.

I think the only real annoyance is that each programmer/team did it with their own convention (I32, INT32, i32, int32, WORD, Word bool, BOOL, Bool, etc., etc.); standardizing helps with putting everyone on the same page more than it helps porting. It doesn't prevent people from reverse-typedef-ing standard names to local "dialectal" names, though.

But I also think that one should only rarely use raw integer types, in an ideal world; the elephant in the room is that typedef is kind of the second "billion dollars mistake" [1]. C is a weakly typed language and there's no practical way to undo it (besides transpilation), so there's double no point to leave behind raw types.

[1] For those not too familiar with C, typedef defines a "type alias", not a type: https://en.cppreference.com/cpp/language/typedef

Re:C's Flexible Integer Sizes Were Not a Design Mistake by pjmlp on Sunday September 27, 2026 @06:16AM (#49865283)
The deal was dealing with #ifdef spaghetti to define all of those, especially when mixing libraries across platforms.
Re:C's Flexible Integer Sizes Were Not a Design Mistake by ykonstant on Sunday September 27, 2026 @03:24PM (#49869954)
Ifdef soup is still horrible, so those times (which I didn't experience firsthand) must have been abysmal.
Re:C's Flexible Integer Sizes Were Not a Design Mistake by sparkie on Sunday September 27, 2026 @05:56PM (#49871263)
If you want to know how bad it can be, only need to take a look at GCC's implementation of `stddef.h` for `size_t` and `ptrdiff_t` etc.

https://github.com/gcc-mirror/gcc/blob/master/gcc/ginclude/s...

There's a simpler way to define these types in newer versions of C which have `typeof`, we can take advantage of the fact that `sizeof()` always returns a `size_t`, `ptr - ptr` always returns a `ptrdiff_t`, and a literal L'c' has type `wchar_t`, etc.

    typedef typeof(sizeof(0)) size_t;
    typedef typeof(nullptr) nullptr_t;
    typedef typeof((void*)0-(void*)0) ptrdiff_t;
    typedef typeof(L'\0') wchar_t;
    typedef typeof(u8'\0') char8_t;
    typedef typeof(u'\0') char16_t;
    typedef typeof(U'\0') char32_t;
Don't need ifdef soup to test what the sizes of things are on different architectures - we just utilize the compiler's implementation of those types.
Re:C's Flexible Integer Sizes Were Not a Design Mistake by someonebaggy on Sunday September 27, 2026 @10:11PM (#49872765)
Traditionally your compiler supported one type of computer and just defined them to what they were on that computer.
Re:C's Flexible Integer Sizes Were Not a Design Mistake by pjmlp on Monday September 28, 2026 @02:41AM (#49874397)
Assuming that you don't need to target older compilers without C23 support, or where that isn't available as language extension.