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