public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: Matthew Joyce <mfjoyce2004@gmail.com>
Cc: Newlib <newlib@sourceware.org>, Joel Sherrill <joel@rtems.org>
Subject: Re: [PATCH 1/1] libc: Added implementations and prototypes for
Date: Thu, 22 Jul 2021 09:55:11 +0200	[thread overview]
Message-ID: <YPkkX5uM/uxSifp6@calimero.vinschen.de> (raw)
In-Reply-To: <CALo2L3MqT7wKo=48FYkR8Q6tJAUrV2X2TaM=crPv3FfuifPs5Q@mail.gmail.com>

Hi Matt,

On Jul 22 07:14, Matthew Joyce wrote:
> Hi Corinna,
> 
> I've made the changes you recommended but I'm running into a problem
> with the definition of SIG2STR_MAX. You suggested:
> 
> #if __STDINT_EXP(INT_MAX) > 0x7fff
> #define SIG2STR_MAX (sizeof ("RTMAX+") + sizeof ("4294967295") - 1)
> #else #define SIG2STR_MAX (sizeof ("RTMAX+") + sizeof ("65535") - 1)

These are actually two lines, right?  It's just a copy/paste glitch,
I guess.

> #endif
> 
> I've tried it both in newlib and natively but I get the error:
> " missing binary operator before token '(' "
> (In the first line of the block)

I hacked a STC:

----------------------------------
#include <stdio.h>
#include <string.h>
#include <stdint.h>

#if __STDINT_EXP(INT_MAX) > 0x7fff
#define SIG2STR_MAX (sizeof ("RTMAX+") + sizeof ("4294967295") - 1)
#else
#define SIG2STR_MAX (sizeof ("RTMAX+") + sizeof ("65535") - 1)
#endif

void
foo (int sig, char *out)
{
  char buf[SIG2STR_MAX];

  if (sig > SIG2STR_MAX)
    return;
  snprintf (buf, SIG2STR_MAX, "FOO+%d", sig);
  memcpy (out, buf, SIG2STR_MAX);
}
----------------------------------

$ gcc -g -O2 -c -Wall foo.c

No error or warning is generated, so I'm puzzled about your problem.

Would you mind to paste the affected code snippet and the full gcc error
output?


Corinna


  reply	other threads:[~2021-07-22  7:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-17 10:10 [PATCH 0/1] Implementation of sig2str/str2sig Matt Joyce
2021-07-17 10:10 ` [PATCH 1/1] libc: Added implementations and prototypes for Matt Joyce
2021-07-19  9:47   ` Corinna Vinschen
2021-07-19 13:19     ` Joel Sherrill
2021-07-19 14:31       ` Corinna Vinschen
2021-07-20  5:11         ` Matthew Joyce
2021-07-22  5:14         ` Matthew Joyce
2021-07-22  7:55           ` Corinna Vinschen [this message]
2021-07-23  5:44             ` Matthew Joyce
2021-07-28  8:44               ` Corinna Vinschen
2021-07-24  8:37 [PATCH 0/1] V2 Implementation of sig2str/str2sig Matt Joyce
2021-07-24  8:37 ` [PATCH 1/1] libc: Added implementations and prototypes for Matt Joyce
2021-07-28  9:11   ` Corinna Vinschen
2021-07-28 15:25     ` Brian Inglis
2021-07-28 18:46       ` Corinna Vinschen
2021-07-28 19:42         ` Joel Sherrill
     [not found]           ` <DM3P110MB0522CE441CAB289B69DE18B49AEA9@DM3P110MB0522.NAMP110.PROD.OUTLOOK.COM>
2021-07-28 19:54             ` Fw: " C Howland
2021-07-28 20:13               ` Joel Sherrill
2021-07-29  9:23                 ` Corinna Vinschen
2021-07-29 15:29                   ` Brian Inglis
2021-07-29 15:29                   ` Brian Inglis
2021-07-29 15:45                     ` Corinna Vinschen
2021-07-29  2:51         ` Brian Inglis
2021-07-28 18:40     ` Corinna Vinschen
2021-07-29  4:59       ` Matthew Joyce
2021-07-29  9:27         ` Corinna Vinschen
2021-07-29 14:41     ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YPkkX5uM/uxSifp6@calimero.vinschen.de \
    --to=vinschen@redhat.com \
    --cc=joel@rtems.org \
    --cc=mfjoyce2004@gmail.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).