Repository navigation
stdintification: use int64_t and INT64_C instead of long long - #5941
Conversation
Even on systems without C99 where long long and stdint are both missing, we can shim stdint and point it to any compiler-specific type (i.e long long, _int64, etc.). Also next is constant suffixes and determining what needs to include stdint.
Passes w/ gcc 11 on Fedora x64. Protip: So you don;t have to suffer, ``` perl -pe 's/(-?(?:0x)?[A-Fa-f0-9]+)([Uu])?[Ll][Ll]/\U$2INT64_C(\E$1)/mg' ```
lhchavez
left a comment
There was a problem hiding this comment.
i'm in favor of this change \o/
since this change doesn't touch deps/ it might not be feasible at the time, but maybe it's worth adding -Wlong-long to one of the gcc CI builds later if it helps prevent backsliding (i.e. if it complains in all/some of the places that this PR touched). if that doesn't work, maybe adding https://clang.llvm.org/extra/clang-tidy/checks/google-runtime-int.html and #5618 will do the trick.
|
I'm also 👍 on this, generally speaking. But I also worry about the long-term drift. Tackling these sort of issues one time is a frustrating experience (and thanks for the endeavor, @NattyNarwhal). But having to revisit them every few months because we aren't catching them in CI is an added frustration that we should avoid. |
the flags or |
For 32-bit int: There's no real reason for that ifdef if we explicitly specify the stdint.h type. For 64-bit int: ope, I made it signed accidentally
ethomson
left a comment
There was a problem hiding this comment.
I noticed one more sign change. Otherwise, this is great, thanks!
While both are C99, the type and macro constant can be used in C89 with shims (i.e the one included).
long longcan't be (and it's a GCC extension), so using the stdint types will be preferable. In addition, we also need to use the macro for constants, because those can differ pre-C99. (As an example, MSVC uses_int64instead oflong long, andi64as the constant suffix instead ofll.)Not touched were things in
deps/; the NTLM library isn't used on Windows and zlib seems to handle MSVC fine already. I assume the changes can be replicated upstreams and synced anyways.Tested with gcc 11 on Fedora 34 x64. (As mentioned in the previous comment, I intend to use this with MSVC, but I'm still cleaning up my branch. 😬 )
Fixes #5939