bizarre extra header file inclusion
I've got a program foo/foo.cc, that includes the following code, stripped down for clarity:
#include "../bar/bar.h"
func ()
{
update_status = update_jobs_table <SequenceIndex, Job_list_by_Sequence::const_iterator>
(jobs_table_update_statement, Normally_Changed_Job_list, UPDATE_CHANGE_DATA);
}
bar.h includes the following template definition:
template <typename Job_bunch_index, typename Job_bunch_const_iterator, typename Job_bunch>
int update_jobs_table (PREPARED_STATEMENT update_stmt, Job_bunch &Updated_Job_bunch, enum jobs_table_update_type update_type);
Now here's the really bizarre part. When I'm in the foo directory and I compile foo.cc
with CC from Sun Studio Express 2 - August 2006, the bar.h header file is included twice
within the compilation: once at the #include, and once at the very end of foo.cc, where
there is no #include at all !!
I can tell where the inclusions are happening by judicious insertion of #if, #define,
and #warning directives, and I can tell it's the processing of this template invocation
that's causing the problem by commenting it out.
It gets scarier yet. If I move bar.h from the bar directory to the foo directory,
and use either
#include "../foo/bar.h"
or
#include "bar.h"
then this double inclusion goes away. Why it would depend on the inclusion path
is truly mystifying.

