This content has been marked as final. Show 2 replies
There are several things that could be wrong.1 person found this helpful
First, check to see if algorithm.cc is explictly included anywhere. If so, change the code so that it only uses a standard include directive:
One possible subtle problem involves the compiler's default behavior in including files having template code. By default, if a template is declared in a header file and is used, the compiler looks for a corresponding .cc (or .cpp, .C, etc) file, and includes it automatically. If the source code was not written with automatic inclusion in mind, you can get duplicate definition errors due to multiple inclusion of the same file.
You can read more about the "definitions-included" and "definitions-separate" template compilation model in the C++ Users Guide, chapter 5, "Program Organization".
However, I don't see how this feature could result in multiple declarations from algorithm.cc, unless the project source code tries to be clever about standard headers, such as including a preprocessed standard header. That is, something like this:
First, check for something odd like the above. If that's not the problem, try adding the option
% cat foo.cc #include <algorithm> % CC -E foo.cc > algo.h # don't do this! % cat myproject.cc #include "algo.h" // don't do this ...
to disable the automatic inclusion of source code files.
If still no joy, please post a small sample program that results in the same error messages.
Thanks for the reply.
algorithm.cc is not being included anywhere.
I did a very brief glance of the code and couldn't find any examples of weird things happening with headers like you were suggesting (again, only a brief glance).
I did try "-template=no%extdef" and that DID fix the problem!