[riot-devel] Coding conventions amendment

Ludwig Knüpfer ludwig.knuepfer at fu-berlin.de
Fri Oct 14 09:13:50 CEST 2016


Hi,

Am 13. Oktober 2016 22:42:11 MESZ, schrieb Kaspar Schleiser <kaspar at schleiser.de>:
>Hi,
>
>On 10/13/2016 09:43 PM, Kees Bakker wrote:
>>>> Does anybody object to adding this to the coding
>>>> >> conventions explicitly?
>>> > What about `size_t`?
>> +1 for size_t
>
>Well, any convention would need careful wording.
>
>```
>for (uint32_t timeout = 1; timeout < (10LU*1000*1000); timeout *= 2) {
>	if(try()) break;
>}
>```
>
>... cannot blindly by convention converted to size_t as loop variable.
>
>IMHO this example also answers Oleg's initial concern: sometimes int or
>unsigned int or size_t just don't work.

Of course there are cases where this default can or should not be applied for various (e.g. type safety, numeric, or optimization) reasons.

In general it is safer to explicate the integer width. As RIOT is targeted at 32 bit architectures, I can also see a rationale for `*int32_t` as the default per convention.

Cheers,
Ludwig


More information about the devel mailing list