function template question
sashan
sashang@ihug.co.nz
Tue Mar 30 00:52:00 GMT 2004
>I am using gcc 3.2.2 and ld 2.13.90.0.2 on RedHat 8 updated. All compilation is
>fine but the linker fails with the following message:
>
>undefined reference to `void Module::forEach<forEachObj>(forEachObj&)'
>
>I assume this means that the compiler did not create the code from the template
>when it say the call to the function in the CellObject.cpp file. Is this
>correct? If so did I do something wrong? Am I missing something here?
>
>
>
Yes, the compiler did not create the code. Basically the problem is that
a non-exported template must be included in every translation unit. In
practice this means move the definition of Module::forEach into the
header file. The other way is to use the export keyword and only Comeau
implements this. Also note that this is gcc mailinglist related to gcc
development - it's not meant to be a C++ help list.
--
sashan
http://www.cs.auckland.ac.nz/~sgov008/
More information about the Gcc
mailing list