3 ms·
C has its limits. If you know where to look
- eqvinox 2y agoThis should be updated for ISO C23's _BitInt(N), which is not equivalent to intN_t (the type promotion rules differ!) (It also supports "uncommon" values of N)
- gregw2 2y agoFYI, there was a semi-related discussion on architectures and bit widths on HN a couple months ago: https://news.ycombinator.com/item?id=41773559 https://news.ycombinator.com/item?id=41773559
- deleted 2y ago[deleted]
- pajko 2y agoNever use fixed-size integers unless you are communicating with hardware, implementing some protocol or manipulating binary files. If some code shared between 8/16-bit and 32/64-bit architectures requires an a least 16-bit type, go for "int". If it requires an at least 32-bit type, go for "long". Also fixed-size integers shall not be printed with standard directives like %d or %u, but the PRId32, PRIu32, PRIx32, etc... macros shall be used from inttypes.h.
- eqvinox 2y ago> ... PRId32, PRIu32, PRIx32, etc... macros shall be used from inttypes.h. Those are superseded by %w64d %w32x etc. in C23. (One of the most practically DX-improving changes in it.)