egcs-1.0 -frepo problem
Dr. Andreas Stuebinger
andreas.stuebinger@mchp.siemens.de
Mon Dec 8 23:53:00 GMT 1997
Hi,
I have a problem with the appended code snippet. As it is it will compile
with gcc-2.7.2 with included repo patch. However, this is not true for
egcs-1.0. Using egcs-1.0 without -frepo is ok, on using it with -frepo
I have to define USE_EXPLICIT_TEMPLATE to get this explicit template.
My system: Linux i586 RedHat 4.1, binutils-2.8.1.0.1-1, libc-5.4.36-1
Thanks,
Andreas
--------------------------------------------------------------------------------
template <class LIST, class T, class CMP>
void lsort(LIST& l, CMP& cmp, T* dummy)
{
// just for fun, here we do nothing
}
template <class T>
class list {
public:
void sort(int (*cmp)(const T&, const T&)) {
lsort(*this, cmp, (int*)0);
}
};
//#define USE_EXPLICIT_TEMPLATE
// If USE_EXPLICIT_TEMPLATE is not defined, then compiling will result in
// a undefined reference linker error on EGCS-1.0 with -frepo. Compiling
// without -frepo is ok.
//
// However, if we compile once with USE_EXPLICIT_TEMPLATE creating a
// suitable .rpo file, then we may undefine USE_EXPLICIT_TEMPLATE as long as
// the .rpo file is not removed!!
#if defined(USE_EXPLICIT_TEMPLATE)
template void lsort <list<int>, int, int (*)(int const &, int const &)>
(list<int> &, int (*)(int const &, int const &), int *);
#endif
int my_cmp(const int& a, const int& b)
{
return 1;
}
int main()
{
list<int> a;
a.sort(my_cmp);
}
More information about the Gcc
mailing list