I wanted to give it a try, but if fails without considering the target attribute ...
> gcc test.c -g > test.c:9:5: error: redefinition of ‘foo’ > int foo () > gcc version 4.9.2 (GCC) (archlinux)
> gcc test.c -g > test.c:9:5: error: redefinition of ‘foo’ > int foo () > gcc version 4.9.2 (GCC) (archlinux)
https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Function-Multiv...
gcc test.cpp -g
or use the c++ compiler explicitly:
g++ test.c -g