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>
> On Sep 13, 2025, at 22:49, Mayuresh <mayuresh%acm.org@localhost> wrote:
>
> On Sat, Sep 13, 2025 at 11:46:26PM +0200, Roland Illig wrote:
>> This definition cannot be used in conditional inclusion directives from
>> the preprocessor. For example:
>
> How about this borrowed from wordsize.h itself from Linux:
>
> #if defined __x86_64__ && !defined __ILP32__
> # define __WORDSIZE 64
> #else
> # define __WORDSIZE 32
> #endif
>
> i.e. are __x86_64__ and __ILP32__ ubiquitous?
It depends on the compiler. I know for sure GCC and Clang support __ILP32__ and __LP64__, so you could do this:
#if !defined(__WORDSIZE)
#if defined(__ILP32__)
#define __WORDSIZE 32
#else
#define __WORDSIZE 64
#endif
#endif
This also works:
#if !defined(__WORDSIZE)
#include <stdint.h>
#if UINTPTR_MAX == UINT32_MAX
#define __WORDSIZE 32
#else
#define __WORDSIZE 64
#endif
#endif
Home |
Main Index |
Thread Index |
Old Index