Ben Pfaff wrote:
> I do agree that 'hamming_weight' is a precise name for this
> function. But it is not a descriptive name: one must know by
> rote what a Hamming weight is.
Yes, 'hamming_weight' does not help the understanding unless you are
already familiar with it.
> Bruno Haible <
bruno@...> continues:
> >> +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4)
> >> +#define POPCOUNT_CALCULATION(NAME) \
> >> + return __builtin_##NAME (x);
> >
> > This will not work with CC="gcc -fno-builtin". Better use an autoconf test.
>
> Actual testing with GCC bears this out:
>
> blp@blp:~/gnulib/gnulib(1)$ cat test.c
> #include <stdio.h>
> int
> main (void)
> {
> printf ("%d\n", __builtin_popcount (5));
> return 0;
> }
> blp@blp:~/gnulib/gnulib(0)$ gcc -Wall -Wextra -fno-builtin test.c
> blp@blp:~/gnulib/gnulib(0)$ ./a.out
> 2
You're right. Sorry, my mistake.
Bruno