Re: [hackers] [quark] Use sizeof() instead of magic constants || FRIGN

From: FRIGN <dev_AT_frign.de>
Date: Mon, 5 Sep 2016 09:44:19 +0200

On Mon, 5 Sep 2016 09:39:24 +0200
Anselm R Garbe <garbeam_AT_gmail.com> wrote:

Hey Anselm,

> Why should I try. This is blatantly obvious wrong code.
>
> I'm referring to NOT using parentheses to make it explicitely clear,
> that the expression is not referring to a type. See sec. 6.5.3 in the
> C lang spec for further details.

why would there ever be a doubt that "unsigned char" is a type? Even if
you use the stdint.h types, e.g. uint8_t, Posix has noticed and taken
measures to make it clear with the _t suffix that uint8_t is a type.

As I mentioned earlier, if you cannot discern a type name from a
variable name it's your problem and should not be "fixed" by having a
strange use of sizeof which is error-prone, as Ali has well shown.
This obviously goes the other way around too. One should not use
variable names that can be misinterpreted as a typename.

Cheers

FRIGN

-- 
FRIGN <dev_AT_frign.de>
Received on Mon Sep 05 2016 - 09:44:19 CEST

This archive was generated by hypermail 2.3.0 : Mon Sep 05 2016 - 09:48:33 CEST