[Insight-developers] ITK_MANUAL_INSTATIATION in txx files

Luis Ibanez ibanez at cs.unc.edu
Tue Jun 27 18:35:18 EDT 2000


Bill Hoffman wrote:

> The normal include guards on thisclass.h will stop that from
happening.
> In fact, that is what we are doing right now.

You're right,
I'm  doing something wrong here....

In fact the problem appears if you try to compile one of the
templated .cxx files (now .txx) without defining the symbol
ITK_MANUAL_INSTANTIATION.

The message looks like:

  templateInclude.cxx:8: redefinition of `testClass<T>::testClass()'
  templateInclude.txx:8: `testClass<T>::testClass()' previously declared
here

What happens is that the header file has the classical guard
to avoid defining the class several times, but the txx doesn't
have a similar kind of guard. So, when trying to compile a txx
directly, it includes the header file, the header file includes the
txx again, and the definitions done in the txx file are seen twice.

---

But, in practice, this files don't need to be directly compiled,
the should instead be included in other files, where the templated
class is instantiated with some specific types.

So, We don't need any additional block in the txx files.


Thanks for the correction,


Luis





More information about the Insight-developers mailing list