Reputation: 12939
I'm having some serious issues with Visual Studio 2013. I have C++ console project with 2 files: Main.cpp and A.cpp, I'm importing A.cpp with #include "A.cpp"
in Main.cpp.
Here is the problem: When I edit A.cpp
and run Main.cpp
, the changes do not occur. I have to change Main.cpp
as well and only then will Visual Studio notice the change and recompile everything properly.
This is extremely annoying when I'm trying to change something in A.cpp
, any idea how to fix this?
EDIT:
I have tried renaming A.cpp
to A.hpp
and include A.hpp
from Main.cpp
with same result: changes to A.hpp
do not occur in build until I change Main.cpp
as well. I have tried putting A.hpp
to both header files and source files in the solution explorer, still the same results.
Upvotes: 0
Views: 263
Reputation: 6407
Never do #include "A.cpp"
! Only h
-files (or hpp
) should be included with #include
. In case you want use in Main.cpp
some functions defined in A.cpp
I have to create A.h
(and do not change A.cpp
) with declarations of that functions. Of course, you need add both Main.cpp
and A.cpp
to project.
NOTE: If you add A.cpp
into VS project and leave #include "A.cpp"
(not #include "A.h"
) this will lead to a problem with redefinition of functions from A.cpp
.
See simple explanation in C++ forum and other examples
Upvotes: 2