test2.c #include int i=0; int main() { printf("%d\n", i); return 0; } ---- test3.cpp: extern "C" int i; class Foo { public: Foo() { i=5; } }; static Foo foo; ---- doener@atjola:~$ gcc -c -o test2.o test2.c doener@atjola:~$ g++ -c -o test3.o test3.cpp doener@atjola:~$ g+ -o test2 test2.o test3.o doener@atjola:~$ ./test2 5