Amule编译问题

 编译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

Name lookup changes

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);
}

Will result in the following diagnostic: 
In instantiation of ‘int t(T) [with T = int]’
  required from here
  error: ‘f’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
  note: ‘int f(int)’ declared here, later in the translation unit


 To fix, make sure the function f in the code above is declared before first use in function t. Like so:

int
f(int i)
{ return i; }

template<typename T>
int t(T i)
{ return f(i); }

int
main()
{
  return t(1);
}

This can be temporarily worked around by using -fpermissive.


总之,是gcc4.7带来的问题,如下配置即可解决:

./configure CPPFLAGS=-fpermissive




你可能感兴趣的:(C++,function,compiler,behavior,translation,Instantiation)