News for hackers. Stuff that matters.
Re:How to C in 2016 by Gankro on Friday January 08, 2016 @07:40AM (#10864429)
If 16 bits is enough, use an explicitly 16-bit integer. If you want something architecture-sized (e.g. because it's dealing with pointers/addresses), use things like `size_t` which makes the intent much more clear, and which are better defined.

In most places, if you're using an `int` for non-address-y stuff you're just wasting space on wider archs, or you're overflowing on less wide ones. The only exception off the top of my head is "I have an array of bytes, but want to bulk process more efficiently than u8 would allow". Things like `size_t` (or explicit SIMD types!) are still probably a better choice there, if only to simplify the rule to "just don't use int".

Re:How to C in 2016 by vardump on Saturday January 09, 2016 @02:19AM (#10870420)
> If 16 bits is enough, use an explicitly 16-bit integer.

This will often generate more code. So don't do this except when it saves a modest amount of memory.

Re:How to C in 2016 by nwmcsween on Saturday January 09, 2016 @01:14AM (#10870309)
You don't know how hardware works...