3 ms·
> These types should be defined in the right header stdint.h It's always been amazing to me how many different projects I've worked on (not that I've been in
by Nursie 3y ago
> These types should be defined in the right header
stdint.h
It's always been amazing to me how many different projects I've worked on (not that I've been in professional C for about 7 years now)) that include their own painstaking recreation of this file.
Reusing them and effectively translating them just to your own name is just annoying to the reader IMHO. I am reminded of a C++ project I worked on, where I questioned the extensive use of typedefs around collections of things, various forms of references and compound objects etc. I was informed by one of the more experienced C++ folks that it made the code easier to comprehend.
Later I saw the typedef cheat-sheet sellotaped to the side of his monitor...
- gallier2 3y agoFor bool it's even worse.
- cesarb 3y ago> It's always been amazing to me how many different projects I've worked on (not that I've been in professional C for about 7 years now)) that include their own painstaking recreation of this file. How many of them started before stdint.h existed? AFAIK, it's a somewhat recent addition to the C language, and IIRC, for a long time even after it became part of the C standard, some popular C compilers still didn't have it.
- deleted 3y ago[deleted]
- Nursie 3y agoAs recently as eight years ago, on projects started within the previous handful of years. It’s more to do with a lot of C programmers being stuck in a sort of stasis IMHO. (I’m sure I was too in many ways). And yes, Microsoft were the outlier and absolutely dragged their heels on stdint, but you could always grab a compliant implementation from one of the FOSS projects that produced one.
- uxp8u61q 3y agointtypes.h was added to C99. A quarter of a century ago.
- yakubin 3y agoMany C codebases predate that. And Visual Studio for a long time didn’t support anything newer than C89.
- eqvinox 3y agoThere's no requirement for a born-1995 codebase to still build on a 1995 system in 2023. I work on a born-1995 codebase. We started requiring an ISO C11 plus GNU extensions¹ several years ago and are actively removing "compatibility" checks and kludges that are outdated. [¹ to be fair - not needing to support Windows is a godsend for any C project.]