Re: [PATCH] ewah/bitmap: silence warning about MASK macro redefinition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eric Sunshine <sunshine@xxxxxxxxxxxxxx> writes:

> On PowerPC Mac OS X (10.5.8 "Leopard" with Xcode 3.1), system header
> /usr/include/ppc/param.h[1] pollutes the preprocessor namespace with a
> macro generically named MASK. This conflicts with the same-named macro
> in ewah/bitmap.c.
>
> [1]: Included indirectly via:
>      git-compat-util.h ->
>      sys/sysctl.h ->
>      sys/ucred.h ->
>      sys/param.h ->
>      machine/param.h ->
>      ppc/param.h
>
> Signed-off-by: Eric Sunshine <sunshine@xxxxxxxxxxxxxx>
> ---
>
> The alternative is to rename MASK in ewah/bitmap.c to something less
> generic, resulting in a slightly more noisy patch. I chose the #undef
> approach since it's a relatively common idiom to #undef a macro before
> #defining it in order to avoid exactly this sort of redefinition
> problem.

I agree that there is nothing controversial against this use of
#undef; I however wonder if we are stomping on _their_ use of MASK
and breaking whatever Mac OS X wants to express with that macro,
though (in which case, hiding collision like this may not be
sufficient and we have to live with the poor implementation choice
made by the header file and change the macro _we_ use).

Will queue.  Thanks.

>  ewah/bitmap.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/ewah/bitmap.c b/ewah/bitmap.c
> index 710e58c..b31cf75 100644
> --- a/ewah/bitmap.c
> +++ b/ewah/bitmap.c
> @@ -20,6 +20,8 @@
>  #include "git-compat-util.h"
>  #include "ewok.h"
>  
> +#undef MASK
> +#undef BLOCK
>  #define MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))
>  #define BLOCK(x) (x / BITS_IN_WORD)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]