AnsweredAssumed Answered

Compiler transparently including .cpp code into another file

Question asked by bbeauchaine87408 on Mar 8, 2010
Latest reply on Mar 23, 2010 by SeanM

So I have a problem with VisualDSP 4.5 that is kicking my ****.


I have a multi-project project group with 6 sub-projects.  Several of the projects are libraries separately compiled and then linked with processor specific code to form the .ldr files for a dual TigerSharc processor board of custom design.


I have a header/source file pair, file1.h and file1.cpp which are compiled into file1.dlb.  file1.h has some function declarations and template code.  file1.h is also included in another file, call it main.cpp that links to file1.dlb to ultimately create a .ldr file.  The issue I am having is that the dependency generator seems to have somehow decided that since I have included file1.h in my main.cpp, it must compile file1.cpp while compiling main.cpp.  The result is multiply defined symbols in the link of main.cpp to its loader file.  I only discovered exactly why I was getting multiple definitions when I moved an #ifdef to the wrong place in file1.cpp and found that my compile of main.cpp broke on the bad line in file1.cpp.


It's acting as if I had a line in main.cpp to the effect of "#include file1.cpp" when I have only included "file1.h".  I've run down all of the include directives and tried to find some backdoor path that would bring file1.cpp into the compile step for main.cpp, but nothing is wrong.  The code compiles and runs correctly in Visual Studio 2005 (we share about 98% of our code base to create simulation .dlls for Windows).