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

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

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

Hey Anselm,

> I disagree. Not using parentheses as sizeof arguments makes it pretty
> clear, that the expression is *not* about the size of a type, but
> rather needs to be evaluated. In dwm/dmenu code this has been
> respected until now for a very long time. I would keep this principle
> in place for other suckless tools as well.

but this only happens if you typedef your structs, which I think is bad
practice.
If you do a
        #typedef struct hw homework
this is your own fault. Using
        sizeof(struct hw)
shows clearly it's a type, whereas
        sizeof(homework)
is not clear. But this is more a criticism of extreme typedeffing. Stop
using typedefs for structs and you won't have this problem any more. If
you can't discern type names from variable names, this is your problem.

Cheers

FRIGN

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

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