Re: [dwm] using bitaray for tags (PATCH)

From: Szabolcs Nagy <>
Date: Wed, 21 May 2008 11:21:51 +0200

On 5/21/08, Enno Gottox Boland <> wrote:
>> the (1 << tagnum) in rules is a bit nasty
>> it is probably nicer to do the shifting in setup();
> you mean in applyrules? - No I don't think so. It adds much more
> flexibility. You can define bitmasks as 0b10001 to tag a client to the
> first and the fifth tag or you can use ~0 to make it "sticky".

i see

(it would be so nice if c had 0bXXX binary int literals..)

>> instead of
>> i < LENGTH(tags) && i < sizeof(int) * 8;
>> what about checking once
>> if(LENGTH(tags) > sizeof(int) * CHAR_BIT)
>> eprint("Maximum number of tags: %d\n", sizeof(int) * CHAR_BIT);
>> in setup();
> The problem about this is it denies users from using one config.h with
> many tags on different architectures. Furthermore I wouldn't check

i thought LENGTH(tags) > INT_BIT does not make sense, but in that case it's ok

probably limiting LENGTH(tags) to 16 is better (simpler, without too
much compromise (i doubt anyone uses more than 16 tags or X on an
architecture with less int bits))

> this at runtime but at compiletime. (maybe we can use "#warning" as
> compromise)

sizeof(type) is not expanded in the preprocessor so
 #if LENGTH(tags) > INT_BIT
 #error too many tags..
doesn't work (so compiletime check with compiler warning/error is not
possible (imho))

> Anyway, the CHAR_BIT constant is a good idea.

it's a bit paranoid, but more conform ;)
Received on Wed May 21 2008 - 11:21:54 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:43:07 UTC