Re: [hackers] [dwm][PATCH] Use proper conversion specifier and don't assume int == 32bits

From: NRK <nrk_AT_disroot.org>
Date: Wed, 16 Feb 2022 19:10:06 +0600

On Wed, Feb 16, 2022 at 01:07:37PM +0100, Laslo Hunhold wrote:
> _AT_all: why not make a static compile-time-check on LENGTH(tags) and vary
> the type accordingly?
>
> #if LENGTH(tags) < 8
> typedef tag_bitmap uint_least8_t;
> #elif LENGTH(tags) < 16
> typedef tag_bitmap uint_least16_t;
> #elif LENGTH(tags) < 32
> typedef tag_bitmap uint_least32_t;
> #elif LENGTH(tags) < 64
> typedef tag_bitmap uint_least64_t;
> #else
> #error "tags-array too long"
> #endif

Hi Laslo,

I don't think this is possible, at least not with the LENGTH macro. The
pre-processor doesn't have access to `sizeof` operator.

- NRK
Received on Wed Feb 16 2022 - 14:10:06 CET

This archive was generated by hypermail 2.3.0 : Wed Feb 16 2022 - 14:12:37 CET