pkgsrc-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: How to patch for: #include <bits/wordsize.h>
Am 13.09.2025 um 23:13 schrieb Mansour Moufid:
>
>> On Sep 13, 2025, at 13:16, Mayuresh <mayuresh%acm.org@localhost> wrote:
>>
>> On Sat, Sep 13, 2025 at 10:45:52AM -0500, Jonathan A. Kollasch wrote:
>>> For a better answer we'd need to see what's in the #if and any #else.
>>
>> It chooses between read_uint32 vs read_uint64 ( and write_uint32 vs
>> write_uint64 ).
>
> wordsize.h is part of glibc, it defines the macro __WORDSIZE to either 32 or 64.
>
> https://fossies.org/linux/glibc/sysdeps/x86/bits/wordsize.h
>
> It's usually safe to do this (with the exception of x32 (ILP32) and maybe others):
>
> #if defined(__GLIBC__)
> #include <bits/wordsize.h>
> #endif
> #if !defined(__WORDSIZE)
> #define __WORDSIZE (sizeof (void *) * 8)
> #endif
This definition cannot be used in conditional inclusion directives from
the preprocessor. For example:
> #if __WORDSIZE == 32
> size.c:5:32: error: missing binary operator before token "("
> 5 | #define __WORDSIZE (sizeof (void *) * 8)
> | ^
> size.c:8:5: note: in expansion of macro ‘__WORDSIZE’
> 8 | #if __WORDSIZE == 32
> | ^~~~~~~~~~
The thing is that in an "#if" directive, the preprocessor does not know
of the "sizeof" operator, and it replaces every unknown word token with
the number 0. So in effect, the line becomes:
> #if (0 (0 *) * 8) == 32
Roland
Home |
Main Index |
Thread Index |
Old Index