[Bug?] SIG2STR_MAX not good for #if
Corinna Vinschen
vinschen@redhat.com
Mon Jun 19 09:00:04 GMT 2023
On Jun 19 14:15, Mingye Wang wrote:
> When building schilytools on MSYS2, I got hit with:
>
> ```
> defs.h:1288:21: error: missing binary operator before token "("
> 1288 | #if NUMBUFLEN < SIG2STR_MAX
> ```
>
> For context, the source goes:
>
> ```
> #define NUMBUFLEN 21 /* big enough for 64 bits */
> #if NUMBUFLEN < SIG2STR_MAX
> #undef NUMBUFLEN
> #define NUMBUFLEN (SIG2STR_MAX-1)
> #endif
> ```
>
> A cursory inspection of /usr/include leads me to this "#define
> SIG2STR_MAX (sizeof("RTMAX+") + sizeof("4294967295") - 1)" definition;
> redefining it with a plain number makes the build go through. Looking
> up the newlib source code, it appears that the definition is not
> specific to MSYS2 or Cygwin, but common to all newlib distributions.
>
> The wording proposed for SIG2STR_MAX by geoffclare in comment 4975[1]
> under the POSIX issue 8 bug report requires that the definition is
> suitable for #if, which newlib currently violates. Now this isn't
> quite standard yet and is subject to change, so I can't say for sure
> this is newlib's bug.
>
> [1]: https://www.austingroupbugs.net/view.php?id=1138#c4975
We could redefine SIG2STR_MAX as static values (still dependent on
__SIZEOF_INT__) and prepend the sizeof expressions as comments.
Do you want to provide a patch?
Thanks,
Corinna
More information about the Newlib
mailing list