[CLAM] Mac OS X progress and template specialization
Maarten De Boer
mdeboer at iua.upf.es
Mon Sep 15 06:55:11 PDT 2003
Hello,
I just solved a problem Mac OS X compilation. I moved to g++ 3.3
(installing Dec2002DevTools and August2003gccUpdater), and the
problem we had before - g++'s preprocessor running out of memory
because of the deep including - is now solved. Now, I ran into
another problem which seems to be apple g++ 3.3 specific. I got a
lot of multiple definitions when linking. I tracked it down to the
template specializations. Consider the following header
template <class T> class A
{
public:
inline void f(void);
};
template <class T> void A<T>::f(void)
{
}
template<>
void A<int>::f(void)
{
}
When this header is included by more then one cxx file, linking result in
ld: multiple definitions of symbol _ZN1AIiE1fEv.eh
a.o definition of absolute _ZN1AIiE1fEv.eh (value 0x0)
b.o definition of absolute _ZN1AIiE1fEv.eh (value 0x0)
ld: multiple definitions of symbol A<int>::f()
a.o definition of A<int>::f() in section (__TEXT,__text)
b.o definition of A<int>::f() in section (__TEXT,__text)
The solution is easy and obvious (tracking down and isolating the problem
not that much): the template specialization should be inlined. (Thanks,
Miguel)
template<>
inline void A<int>::f(void)
{
}
Now, this appearantly is only necesary with g++ 3.3 (mac os x), but it
does not cause any problem with the other g++ versions, nor with visual,
so I am adding the inline stuff where necesary now. I also made some
other small changes for Mac OS X, including the build system, and I think
a release supprting Mac OS X is becoming more and more feasible quickly.
Maarten
More information about the clam-users
mailing list