编译aMule-2.3.1源码时竟然遇到了错误:
ObservableQueue.h: In instantiation of ‘void CObservableQueue<ValueType>::ObserverRemoved(CObservableQueue<ValueType>::ObserverType*) [with ValueType = CPartFile*; CObservableQueue<ValueType>::ObserverType = CObserver<CQueueEvent<CPartFile*> >]’:
DownloadQueue.cpp:1665:1: required from here
ObservableQueue.h:341:2: error: ‘NotifyObservers’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation
找了3个小时才找到原因,在这里:
http://gcc.gnu.org/gcc-4.7/porting_to.html
The C++ compiler no longer performs some extra unqualified lookups it had performed in the past, namely dependent base class scope lookups and unqualified template function lookups.
C++ programs that depended on the compiler's previous behavior may no longer compile. For example, code such as
template<typename T> int t(T i) { return f(i); } int f(int i) { return i; } int main() { return t(1); }
int f(int i) { return i; } template<typename T> int t(T i) { return f(i); } int main() { return t(1); }
总之,是gcc4.7带来的问题,如下配置即可解决:
./configure CPPFLAGS=-fpermissive