If you're using #include "exception.h"
in exception.c, graph.c, io.c, and every other C source file in your project, then that's the equivalent of copying the contents of exception.h into the top of every C source file.
That means that in each C source file, there's an _ErrorCode
variable defined. When the object files from each C source file are linked, since __ErrorCode
is defined in each object file, that's a naming conflict.
The solution is to use extern
as Dabo suggests - if you use extern const char* __ErrorCode[];
in the header file, then each object file will know to expect an __ErrorCode
variable defined elsewhere. Then, you can define the variable in exception.c. During linking, the extern
variables will all be resolved to the __ErrorCode
defined in exception.c.