I have dll project that includes additionally A.h header file. A.cpp includes A.h and B.cpp that has o header. If I do add B.cpp to visual c++ project compiler reports many errors :
Error 9 error LNK2005: "wchar_t * __stdcall aaa(int)" (?aaa@@YGPA_WH@Z) already defined in A.obj C:\P\B.obj pr1
There are no problems and project compiles fine in case if I leave B.cpp in project directory, but not add it to project.
That is the problem with adding B.cpp file?
#includeis for header files, not other .cpp files.Remove
#include "B.cpp"from A.cpp, and things will start behaving properly.Or rename B.cpp to B.h if you intend to include it.