Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sun, 7 Apr 2013 17:21:31 +0200
From: Szabolcs Nagy <>
Subject: Re: [PATCH] String: expand to word size && refactor ||

* Jens Gustedt <> [2013-04-07 16:31:37 +0200]:
> > 
> > the unsigned -1 idiom is used a lot in musl anyway
> hm, for macros I really would be more cautious. Couldn't one day such
> a macro end up in a #if directive? Then using the named macro would be
> better since this then gives the same value for the
> preprocessor.

yes this is clearly not preprocessor safe but that was not the goal

it's annoying that the preprocessor handles numbers as [u]intmax_t,
otherwise no bits/stdint.h or bits/limits.h were needed, you could
define all the limits in terms of -1U, -1UL, -1ULL

one could say that cpp is simpler this way but it still has to know
a lot of things eg wide characters should work: musl uses
#if L'0'-1 > 0 to determine if wchar_t is unsigned

> > the really clear definition would be (size_t)0x0101..01 but it
> > depends on the word size
> that should be (size_t)+0x0101..01 such that it can be evaluated in
> the preprocessor.

nice trick..

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.