[Issue 23509] ImportC: Unable to parse GLibC assert.h's assert (and other nontrivial macros?)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 12 11:27:39 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=23509

Krzysztof Jajeśnica <krzysztof.jajesnica at student.put.poznan.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |krzysztof.jajesnica at student
                   |                            |.put.poznan.pl

--- Comment #2 from Krzysztof Jajeśnica <krzysztof.jajesnica at student.put.poznan.pl> ---
I accidentally hit the same bug while trying to compile the Nuklear library
with DMD 2.101.1 on Manjaro Linux.

Based on the error message and source code of assert.h I think ImportC is
trying to use the following definition of assert:

#  define assert(expr)                                                  \
  ((void) sizeof ((expr) ? 1 : 0), __extension__ ({                     \
      if (expr)                                                         \
        ; /* empty */                                                   \
      else                                                              \
        __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION);   \
    }))

The problem seems to be caused by 2 GCC extensions used in the assert macro
which are not supported by ImportC:

1. Statement expressions
(https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html)
   (basically GCC treats code like this: ({statement1; statement2;}) as an
expression)

2. __PRETTY_FUNCTION__ - this one is hidden inside the __ASSERT_FUNCTION macro

--


More information about the Digitalmars-d-bugs mailing list