Should importC fail on invalid C code?

kdevel kdevel at vogtner.de
Fri Jan 13 12:50:44 UTC 2023


After reading Walter's remark "ImportC sees those macro 
definitions and transforms them into manifest constant 
declarations" in

     Issue 23622 - ImportC #defines conflict with declarations

I wondered how it was implemented:

`myccode.c`
```
int getx ()
{
    return X;
#define X 1
}
```

`imc.d`
```
unittest {
    import myccode;
    assert (false, "Should img.c really compile?");
}
```

```
dmd -O -checkaction=context -unittest -main myccode.c -run imc.d
imc.d(3): [unittest] Should img.c really compile?
1/1 modules FAILED unittests
```


More information about the Digitalmars-d-learn mailing list