bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Jeffrey Walton <noloader@gmail.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Bruno Haible <bruno@clisp.org>, bug-gnulib@gnu.org
Subject: Re: assert-h: Make static_assert work on Solaris 11.4
Date: Tue, 25 Oct 2022 14:18:52 -0400	[thread overview]
Message-ID: <CAH8yC8=WGJhBK+QCywRp_F4J2dZkrNMqdhFg7gvx5c5B5bipNQ@mail.gmail.com> (raw)
In-Reply-To: <c89e144a-667c-f3fb-a1fa-a4be421d7966@cs.ucla.edu>

On Tue, Oct 25, 2022 at 2:13 PM Paul Eggert <eggert@cs.ucla.edu> wrote:
>
> On 2022-10-23 07:47, Bruno Haible wrote:
> >    #include <assert.h>
> >    #undef/**/assert
> > + /* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments.
> > +    We need it also to be invocable with a single argument.  */
> > + #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus
> > +  #undef static_assert
> > +  #define static_assert _Static_assert
> > + #endif
> >   #endif])
>
> Will this approach work if code does something like the following? I
> worry that the later <assert.h> includes would collide with config.h's
> definition of static_assert.
>
>    #include <config.h>
>
>    #define NDEBUG 1
>    #include <assert.h>
>
>    #define NDEBUG 0
>    #include <assert.h>
>
>    static_assert (true);
>
> Come to think of it, the latest C23 draft is a little squirrelly here,
> as its section 7.2 says that <assert.h> defines a static_assert macro.
> This must be a typo because it never goes no to say anything about what
> the macro does, and static_assert is a keyword in C23.
>
> Also, while we're on the topic, why does the latest C23 draft require
> that when NDEBUG is defined, the assert macro is defined via "#define
> assert(...) ((void)0)" rather than as "#define assert(ignore)
> ((void)0)"? What's the point of requiring the ellipsis?

Re: the ellipses. From
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2264r3.html,
Section 8:

    These changes are relative to N2573. If those changes are
    applied the minimal change for C++ standard proposed above
    could be used.

    In section 7.2 (Diagnostics <assert.h>) change the
    definition of the assert() macro to use elipsis instead of
    a single macro parameter:
    ...

Jeff


  reply	other threads:[~2022-10-25 18:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-23 14:47 assert-h: Make static_assert work on Solaris 11.4 Bruno Haible
2022-10-25 18:12 ` Paul Eggert
2022-10-25 18:18   ` Jeffrey Walton [this message]
2022-10-25 18:22     ` Paul Eggert
2022-10-25 20:11       ` Bruno Haible
2022-10-25 21:47         ` Paul Eggert
2022-10-26  0:17           ` Bruno Haible
2022-10-25 20:05   ` Bruno Haible

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

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to='CAH8yC8=WGJhBK+QCywRp_F4J2dZkrNMqdhFg7gvx5c5B5bipNQ@mail.gmail.com' \
    --to=noloader@gmail.com \
    --cc=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    /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).