The problem is that inside the first module named A.cpp name a has C++ language linkage that is it in fact is declared as
extern "C++" int a;
int a = 5;
While inside the second module named b.c name a has C language linkage because this module was compiled as C-code by the compiler.
So this name denotes two different entities in your project.
There are two methods to avoid the error.
The first is to compile the second module as C++ code. I think it will be enough to rename the module from b.c to b.cpp.
The second is to declare variable a as having the C language linkage in the first module
extern "C" int a = 5;
It is better even to combine the variable and the function in one language linkage specification in the fiirst module because the function also has C langauge specification