bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: assert-h: Make static_assert work on Solaris 11.4


From: Jeffrey Walton
Subject: Re: assert-h: Make static_assert work on Solaris 11.4
Date: Tue, 25 Oct 2022 14:18:52 -0400

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 via email to

[Prev in Thread] Current Thread [Next in Thread]