www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23509] New: ImportC: Unable to parse GLibC assert.h's assert

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

          Issue ID: 23509
           Summary: ImportC: Unable to parse GLibC assert.h's assert (and
                    other nontrivial macros?)
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: kipthemudkip yahoo.com

Just tried building the Mosquitto MQTT library (specifically just the client
library) on Artix Linux x64 solely with DMD master. I tried the following:

cd lib
dmd-master -P=-I../ -P=-I../deps *.c

...and got some errors on every mention of assert(). Try just one file to see
what I mean:

dmd-master -P=-I../ -P=-I../deps messages_mosq.c

messages_mosq.c(52): Error: expression expected, not `{`
messages_mosq.c(52): Error: found `if` when expecting `)`
messages_mosq.c(52): Error: found `;` when expecting `)`
messages_mosq.c(52): Error: found `else` when expecting `;` following statement
messages_mosq.c(52): Error: no type for declarator before `)`
messages_mosq.c(54): Error: no type for declarator before `for`
messages_mosq.c(54): Error: no type for declarator before `(`
messages_mosq.c(54): Error: no type for declarator before `(`
messages_mosq.c(56): Error: no type-specifier for declarator
messages_mosq.c(56): Error: found `;` when expecting `)`
messages_mosq.c(57): Error: `=`, `;` or `,` expected to end declaration instead
of `}`
messages_mosq.c(58): Error: no type for declarator before `(`
messages_mosq.c(58): Error: no type for declarator before `(`
messages_mosq.c(60): Error: no type-specifier for declarator
messages_mosq.c(60): Error: found `;` when expecting `)`
messages_mosq.c(61): Error: `=`, `;` or `,` expected to end declaration instead
of `}`
messages_mosq.c(68): Error: no type-specifier for declarator
messages_mosq.c(69): Error: no type-specifier for declarator
messages_mosq.c(70): Error: no type for declarator before `if`
messages_mosq.c(71): Error: no type-specifier for declarator

If I comment out all uses of assert() (including in deps/utlist.h), I get
similar errors from the use of the DL_DELETE macro in deps/utlist.h:

messages_mosq.c(154): Error: found `else` when expecting `while`
messages_mosq.c(154): Error: found `{` when expecting `(`
messages_mosq.c(157): Error: found `;` when expecting `)`
messages_mosq.c(158): Error: found `}` when expecting `;` following terminating
`;` required after do-while statement
messages_mosq.c(193): Error: `=`, `;` or `,` expected to end declaration
instead of `{`
messages_mosq.c(246): Error: found `}` when expecting `while`
messages_mosq.c(247): Error: found `;` when expecting `(`
messages_mosq.c(248): Error: expression expected, not `if`
messages_mosq.c(248): Error: found `{` when expecting `)`
messages_mosq.c(249): Error: found `return` when expecting `;` following
terminating `;` required after do-while statement
messages_mosq.c(249): Error: type-specifier missing for declaration of
`MOSQ_ERR_SUCCESS`
messages_mosq.c(253): Error: found `else` without a corresponding `if`
statement
messages_mosq.c(267): Error: found `}` when expecting `while`
messages_mosq.c(269): Error: found `;` when expecting `(`
messages_mosq.c(270): Error: expression expected, not `if`
messages_mosq.c(270): Error: found `{` when expecting `)`
messages_mosq.c(271): Error: found `return` when expecting `;` following
terminating `;` required after do-while statement
messages_mosq.c(271): Error: type-specifier missing for declaration of
`MOSQ_ERR_SUCCESS`
messages_mosq.c(279): Error: `=`, `;` or `,` expected to end declaration
instead of `{`

Wondering what the deal is here...

--
Nov 25 2022