[Issue 23441] New: importc: array length macro preprocessed with cpp doesn't compile
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 28 00:29:02 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23441
Issue ID: 23441
Summary: importc: array length macro preprocessed with cpp
doesn't compile
Product: D
Version: D2
Hardware: x86_64
OS: All
Status: NEW
Severity: blocker
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ryuukk.dev at gmail.com
The following code:
```
--- test.d
import bar;
void main()
{
int len;
foo(&len);
}
--- bar.c
struct nk_utfmask
{ int test; };
void foo(int* i)
{
// #define NK_LEN(a) (sizeof(a)/sizeof(a)[0])
// for(*i = 0; *i < (int)NK_LEN(nk_utfmask); ++(*i))
// expended using `cpp -E` on linux
//
for(*i = 0; *i < (int)(sizeof(nk_utfmask)/sizeof(nk_utfmask)[0]); ++(*i)) {
}
}
```
Error:
bar.c(10): Error: found `[` when expecting `)`
bar.c(10): Error: found `0` when expecting `;` following `for` condition
bar.c(10): Error: expression expected, not `]`
bar.c(10): Error: found `)` when expecting `;` following statement
Apparently it's not valid C11, but that's the preprocessor output, so i'm not
sure what i should do, i lack understanding on the syntax itself unfortunately
--
More information about the Digitalmars-d-bugs
mailing list