c++ - Compiler error with templates and boost -


i'm creating small thread management object use start threads (for now) in more generic fashion in programs. template based , using boost threads underlying thread "engine". intend use cross platform wrapper replace legacy code porting linux.

the basic implementation of code looks this:

using mythread = boost::thread;   class threadmanager { public:     threadmanager();     ~threadmanager() {}      template<class _fn, class... _args>     mythread* createthreadptr(unsigned int priority, ::std::string& name, unsigned int stacksz, _fn&& func, _args&&... args)     {         //boost::thread::attributes attrs;         //attrs.set_stack_size(1024);         //boost::thread t{attrs, thread};          mythread* t = new mythread(func, args...);         void* hndl = (void*)t->native_handle();         if (hndl)         {             #ifdef win32             bool res = setthreadpriority(hndl, priority);             if (!res)             {                 //dwerror = getlasterror();             }             #else              //todo              #endif              setthreadname(t, name);              return t;         }          return null;     }      void setthreadname(thandle thread, ::std::string& threadname); #ifdef win32     void setthreadname(thread_id threadid, ::std::string& threadname); #endif #ifdef __linux__     void setthreadname(void* hthread, ::std::string& threadname); #endif      thread_id getthreadid(); };  threadmanager& man(void); 

which used this:

m_txrxthread = man().createthreadptr(priority, thread_name, 0,threadproctxrx, this); 

but when build error

/usr/include/boost/bind/bind.hpp:253:35: error: invalid conversion 'ceth*' 'long unsigned int' [-fpermissive] 

with -fpermissive seems work fine, makes no sense me , want know doing wrong here!

thanks in advance!

-- edit --

threadproctxrx method of ceth object signature

void ceth::threadproctxrx(ul32 lpparam) 

where ul32 typedef unsigned long...

and writing last sentence proverbial light bulb light up... of course needs ul32. focusing onthreadproctxrxwhen error pointed tothis`.

well... praetorian asking clarification. if want put in answer i'll credit that.

-fpermissive

downgrade diagnostics nonconformant code errors warnings. thus, using -fpermissive allow nonconforming code compile.

by compiling -fpermissive downgrading errors code warning compile. should avoid doing this.

what's happing code you're trying assign unsigned long type of ceth*. need static_cast return unsigned long if possible or check return types correct.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -