file.d:
extern(C) { int x = 0; void setx(); void printx(); } void main() { setx(); // sets x = 42 writeln(x); // prints x = 0 printx(); // prints x = 42 x = 7; printx(); // prints x = 42 } file.c: #include <stdio.h> extern int x; void setx() { x = 42; } void printx() { printf("%d\n", x); } Output: 0 42 42