Re: [Bug?] SIG2STR_MAX not good for #if

Joel Sherrill <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CAF9ehCV-u5ud0FmWR8qFLSg_9LaeYfvmF6CVm6-Lth7Heby2dg@mail.gmail.com>
On Mon, Jun 19, 2023, 4:00 AM Corinna Vinschen <[email protected]> wrote:

> 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.
>

FWIW This appears to be a common extension and ere does not appear in the
POSIX standard.

Given that, it should be compatible with glibc

--joel

>
> Do you want to provide a patch?
>
>
> Thanks,
> Corinna
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.