I have a project in DevStudio that contains two files, main.cpp and foo.c:
/* main.cpp */
int glbl = 5;
extern "C" void foo();
int main(int argc, char *argv)
/* end of main.cpp */
/* foo.c */
extern int glbl;
printf("foo: glbl = %d\n", glbl);
/* end of foo.c */
When building, there are no compilation errors, but the linker gives me:
foo.obj : error LNK2001: unresolved external symbol _glbl
Debug/CPP_C_externs.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
It seems that the definition of the global variable glbl is invisible in foo.c. How can I fix this?