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

From: Kurt H Maier <karmaflux_AT_gmail.com>
Date: Tue, 20 May 2008 11:22:19 -0500

C has bitfield support inside structs:

unsigned tagsapplied :8;

and replace 8 with whatever value you want

Bitfields are a bad idea imo; code has to be changed pretty severely
to handle a varying-sized bitfield. You'd have to either limit the
number of tags a user can create or else do a lot of work to
generalize the code.

On Tue, May 20, 2008 at 11:15 AM, Premysl Hruby <dfenze_AT_gmail.com> wrote:
> Hi,
>
> This is realization of Gottox's proposal discuted on IRC today.
> It handles tags not as Bool [], but as bit-array saved in int.
>
> There's only one problem, as I don't find easy solution (in compile time)
> for check if there's no more tags than sizeof(int)*8.
>
> Maybe it can be "asserted" with someting like (possibly global, compiler
> take it away as it's not used anywhere):
>
> static char too_many_tags_test[sizeof(int)*8 - LENGTH(tags)];
>
> Has anyone better solution?
>
> -Ph
>
> --
> Premysl "Anydot" Hruby, http://www.redrum.cz/
>

-- 
# Kurt H Maier
Received on Tue May 20 2008 - 18:22:25 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:42:34 UTC