#include "B.c"
You include the C
file so there is only one compilation unit and static functions are visible in this unit. Basically, the content of the file B.c
is inserted into the A.c
file and the compiler is compiling one file.
It is not the storage class, only the linkage.we change the storage class to static
static
functions do not have external linkage.
To get the behavior required (i.e., unresolved symbols), you need to have two separate compilation units, and after the compilation, they have to be linked together.
In your example, remove the #include "B.c"
and it will stop to link.
Generally, never include '.c' files or define functions or data in the header files.