Comment #0 by emteria_wegwerf — 2023-04-28T15:05:11Z
Created attachment 1872
files needed for reproduction
DMD64 D Compiler v2.103.0
dmd test.c
fails for attached test.c / my_assert.h with
test.c(8): Error: expression expected, not `{`
When I run the preprocessor command dmd claims to use, I get the attached test.i which does not compile with dmd either.
my_assert.h is a copy of the system's assert.h
System is x64 linux with gcc 12.2.1.
Comment #1 by bugzilla — 2023-04-28T19:09:24Z
The error message I get is:
test.c(6): Error: undefined identifier `NULL`, did you mean `null`?
Is that what you got? NULL is not defined in test.i. NULL is supposed to be a macro defined in <stddef.h>.
gcc also complains that NULL is undefined.
Comment #2 by emteria_wegwerf — 2023-04-29T06:52:34Z
I get
$ dmd test.i
test.c(8): Error: expression expected, not `{`
test.c(8): Error: found `if` when expecting `)`
test.c(8): Error: found `;` when expecting `)`
test.c(8): Error: found `else` when expecting `;` following statement
test.c(8): Error: no type for declarator before `)`
test.c(10): Error: no type for declarator before `return`
test.c(11): Error: no type for declarator before `}`
This also happens if I replace NULL with 0 in test.c. After that, gcc compiles the (regenerated) test.i
Comment #3 by schveiguy — 2023-04-30T02:25:10Z
Walter, this is the same issue I got when building stb_image.h (one of them)
The file I used is here: https://github.com/raysan5/raylib/blob/4.0.0/src/external/stb_image.h
The C file I tried to compile is:
```c
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
```
The errors I get are:
```
/usr/lib/gcc/x86_64-linux-gnu/11/include/xmmintrin.h(1016): Error: expression expected, not `__attribute__`
/usr/lib/gcc/x86_64-linux-gnu/11/include/xmmintrin.h(1016): Error: found `int` when expecting `)`
/usr/lib/gcc/x86_64-linux-gnu/11/include/xmmintrin.h(1017): Error: found `{` when expecting `;` following `return` statement
/usr/lib/gcc/x86_64-linux-gnu/11/include/xmmintrin.h(1017): Error: found `}` when expecting `;` following statement
/usr/lib/gcc/x86_64-linux-gnu/11/include/xmmintrin.h(1017): Error: found `)` instead of statement
stb_image.h(1249): Error: expression expected, not `{`
stb_image.h(1249): Error: found `if` when expecting `)`
stb_image.h(1249): Error: found `;` when expecting `)`
stb_image.h(1249): Error: found `else` when expecting `;` following statement
stb_image.h(1249): Error: no type for declarator before `)`
stb_image.h(1251): Error: no type for declarator before `if`
stb_image.h(1253): Error: no type-specifier for declarator
stb_image.h(1254): Error: no type for declarator before `}`
stb_image.h(1258): Error: no type for declarator before `if`
stb_image.h(1260): Error: found `,` when expecting `)`
stb_image.h(1260): Error: `=`, `;` or `,` expected to end declaration instead of `*`
stb_image.h(1261): Error: no type for declarator before `}`
stb_image.h(1263): Error: no type for declarator before `return`
stb_image.h(1264): Error: no type for declarator before `}`
stb_image.h(1275): Error: expression expected, not `{`
```
The errors in stb_image.h are assert calls. The ones deep in xmmintrin.h are some sort of vector call, probably an intrinsic. The code is:
```c
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_move_ss (__m128 __A, __m128 __B)
{
return (__m128) __builtin_shuffle ((__v4sf)__A, (__v4sf)__B,
__extension__
(__attribute__((__vector_size__ (16))) int)
{4,1,2,3});
}
```
Comment #4 by bugzilla — 2023-05-02T02:16:11Z
(In reply to emteria_wegwerf from comment #2)
> I get
>
> $ dmd test.i
> test.c(8): Error: expression expected, not `{`
This is because of the expression statement. This problem was fixed with:
https://github.com/dlang/dmd/pull/15093
Comment #5 by bugzilla — 2023-05-02T02:19:02Z
(In reply to Steven Schveighoffer from comment #3)
> Walter, this is the same issue I got when building stb_image.h (one of them)
Your's appears to be a completely different problem, which is:
__attribute__((__vector_size__ (16))) int
Comment #6 by bugzilla — 2023-05-02T03:13:40Z
Therefore, since the original bug for this issue was fixed, I created a new issue from Steven's report.
https://issues.dlang.org/show_bug.cgi?id=23875
and closed this one as already fixed.