c++ - Windows and Linux : Including cpp files -


i have file a.cpp , b.cpp. latter contains utility functions in use a.cpp.

in linux can following in a.cpp :-

#include "b.cpp" 

and use function in b.cpp.

in windows, visual studio complained not find "b.cpp". changed line follows :-

#include "./b.cpp" 

however, when build project belongs lnk error messages :-

b.obj : error lnk2005 : "unsigned char __cdecl blah() defined in a.obj" 

why happen?

visual studio compiles every cpp file (they included in build default). tries compile b.cpp, a.cpp (with b.cpp), when compile use a.cpp got confused, blah use? obj file? a.obj or b.obj?

the solution simple, don't include .cpp, make .h declarations of functions, , include it.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -