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: Paul Eggert
Subject: Re: assert-h: Make static_assert work on Solaris 11.4
Date: Tue, 25 Oct 2022 11:12:22 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3

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?



reply via email to

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