2013-05-01 1 views
0

CDevVS890 내에서 m_callback_fn을 호출 할 때 CVS890Executor :: do_full_frame을 실행하는 것이 목적입니다. 파일에서tr1 :: function을 사용할 때의 컴파일 오류

이 /usr/lib/gcc/x86_64-redhat-linux/4.4에서 포함 :

"CDevVS890.h" 
typedef std::tr1::function<void (void* frame, int len)> DoFrameFn; 

class CDevVS890 
{ 
public: 
    CDevVS890(); 

    void receive(); 

    DoFrameFn m_callback_fn; 
} 

"CDevVS890.cpp" 
void CDevVS890::receive() 
{ 
    ... 
    m_callback_fn((void*)frame, (int)len); 
} 

/*----------------------------------------------------------------------*/ 

"CVS890Executor.h" 
class CVS890Executor 
{ 
public: 
    CVS890Executor(); 

private: 
    void hookup_to_DevVS890(); 
    void do_full_frame(void* frame, int len); 
} 

"CVS890Executor.cpp" 
CVS890Executor::CVS890Executor() 
{ 
    hookup_to_DevVS890(); 
} 

void CVS890Executor::hookup_to_DevVS890() 
{ 
m_pDevVS890 = new CDevVS890(); 
m_pDevVS890->m_callback_fn = 
    std::tr1::bind(&CVS890Executor::do_full_frame, this, _1); 
} 

void CVS890Executor::do_full_frame(void* frame, int len) 
{ 
    ... 
} 

오류가 읽을 여러 매우 어려운 : 다음

는 incriminated 코드입니다. 6 /../../../../ include/C++/4.4.6/tr1/functional : 56, ../../src/Common/CDevVS890.h:17, 에서 CVS890Executor. h : 13, CVS890Executor.cpp : 8 : /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/ tr1_impl/functional : 멤버 함수에서 âtyp ename std :: tr1 :: result_of < _Functor (typename std :: tr1 :: result_of 0)> (_ Bound_args, std :: tr1 :: tuple < _UElements ...>)> :: 유형 ...) :: :: 형식 std :: tr1 :: _ Bind < _Functor (_Bound_args ...)> :: __ call (const std :: tr1 :: tuple < _UElements ...> &, std :: tr1 :: _ Index_tuple < _Indexes ...>) _Args = void * &, int &, int ... _ 인덱스 = 0, 1, _Functor = std :: tr1 :: _ Mem_fn, _Bound_args = CVS890Executor *, std :: tr1 :: _ 자리 표시 자 < 1> /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/tr1_impl/functional:1191 : âtypename std에서 인스턴스화 됨 :: tr1 :: result_of < _Functor (typename std :: tr1 :: result_of 0)> (_ Bound_args, std :: tr1 :: tuple < _UElements ...>) :: :: ...) :: :: std :: : tr1 :: _ Bind < _Functor (_Bound_args ...) :: operator() (_ Args & ...) _Args = void *, int, _Functor = std :: tr1 :: _ Mem_fn, _Bound_args = CVS890Executor *, std :: tr1 :: _ 자리 표시 자 < 1>]/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/tr1_impl/기능 : 1668 : __static void std :: tr1 :: _ Function_handler :: _ M_invoke (const std :: tr1 :: _ Any_data &, _ArgTypes ...)에서 인스턴스화 _Functor = std :: tr1 :: _ Bind (CVS890Executor * std :: tr1 :: _ 자리 표시 자 < 1>)>, _ArgTypes = void *, int] A /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../ .. /include/c++/4.4.6/tr1_impl/functional:2005 : âstd :: tr1 :: function에서 인스턴스화했습니다. < _Res (_ArgTypes ...)> :: function (_Functor, typename __gnu_cxx :: __ enable_if < (! stf :: tr1 :: is_integral :: value), std :: tr1 :: function < _Res (_ArgTypes ...)> :: 쓸데없는> :: _type) [_Functor = std :: tr1 :: _ Bind (CVS890Executor *, std :: tr1 :: _ 자리 표시 자 < 1>)>, _Res = void, _ArgTypes = void *, int] â /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../. ./../../include/c++/4.4.6/tr1_impl/functional:1885 : __nameu_cxx :: __ enable_if <에서 인스턴스화 (! std :: tr1 :: is_integral :: value), std :: tr1 :: 함수 < _Res (ArgTypes ...)> &> :: _type 표준 : TR1 :: 함수 < _Res (_ArgTypes ...)> :: = 연산자 (_은 Functor)와 _Functor = 표준 : TR1 :: _Bind (CVS890Executor *, std :: tr1 :: _ 자리 표시 자 < 1>), _Res = void, _ArgTypes = void *, int] â CVS890Exec utor.cpp : 115 : 여기에서 인스턴스화 /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/tr1_impl/functional : 1137 : 오류 : â (std :: tr1 :: _ Mem_fn) (CVS890Executor * &, void * &)에 대한 호출과 일치하지 않음 â /usr/lib/gcc/x86_64-redhat-linux/4.4.6/ .. /../../../include/c++/4.4.6/tr1_impl/functional:546 : 참고 : 후보자는 : _Res std :: tr1 :: _ Mem_fn < _Res (_Class :: *) (_ ArgTypes ...)> :: operator() (_ Class &, _ArgTypes ...) const [_Res = void, _Class = CVS890Executor, _ArgTypes = void *, int] /usr/lib/gcc/x86_64-redhat-linux/4.4. 6 /../../../../include/C++/ 4.4.(_Class :: *) (_ ArgTypes ...)> :: 연산자() (_ 클래스 *, _ArgTypes ...) const [함께 _Res = void, _Class = CVS890Executor, _ArgTypes = void *, int] /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4 0.6/tr1_impl/기능 : 1137 : 오류 : 함수 반환 '무효' 메이크업에, 값으로 문을 반환 :이 뭐가 잘못 * [CVS890Executor.o] 오류 1

어떤 생각을?

건배

+0

시간을내어 읽으면 오류를 읽기가 어렵지 않습니다. 확실히 많은 텍스트가 있지만, 시도해 보면 가치가 있다는 것을 확신합니다. – mah

답변

1

당신은 두 번째 인수에 대해 잊어 버렸습니다. bind 기능의 전화는 다음과 같이해야합니다 : CVS890Executor에서

std::tr1::bind(&CVS890Executor::do_full_frame, this, _1, _2); 
//              ^^ 
+0

훌륭하게, 감사합니다. 다른 스레드의 대답을 사용했지만 _1의 목적을 이해하지 못했습니다. 건배! – user2339035

0

:: hookup_to_DevVS890(), 당신은 멤버 함수 do_full_frame에 인수 바인딩되지 않습니다.

또한 함수의 반환 값을 m_callback_fn에 지정하려고 시도하지만 do_full_frame()이 void (반환 값 없음)를 반환하도록 선언되었습니다.

+0

도움 주셔서 감사합니다. – user2339035

관련 문제