Hey,
I have a program that has 5 files, 2 header files called:
console.h
screen.h
and 3 source files called:
a2main.cpp
screen.cpp
console.c //not a typo
When I copy the main
from my a2main.cpp file to my screen.cpp my program compiles without a problem. But when I try and compile it using the external main I get the following errors.
screen.obj : error LNK2005: _line already defined in a2main.obj
screen.obj : error LNK2005: _cursor_pos already defined in a2main.obj
screen.obj : error LNK2005: _col already defined in a2main.obj
a2main.exe : fatal error LNK1169: one or more multiply defined symbols found
Could someone please explain why I am getting these errors.
Also please note that the variables mentioned in the errors are not used at all in a2main.cpp they were declared in console.c then redeclared in screen.cpp.
I have used:
extern "C" {
#include "console.h"
}
in both my a2main.cpp and screen.cpp as the objects and functions in them are called by the main.
Thanks.