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