C++ 模板和boost的编译器错误

C++ 模板和boost的编译器错误,c++,multithreading,boost,C++,Multithreading,Boost,我正在创建一个小的线程管理对象,用于在我的程序中以更通用的方式启动线程(目前)。它是基于模板的,我使用boost线程作为底层线程“引擎”。我打算用它作为一个跨平台的包装器来替换我正在移植到linux的一些遗留代码 我的代码的基本实现如下所示: using mythread = boost::thread; class ThreadManager { public: ThreadManager(); ~ThreadManager() {} template<cl

我正在创建一个小的线程管理对象,用于在我的程序中以更通用的方式启动线程(目前)。它是基于模板的,我使用boost线程作为底层线程“引擎”。我打算用它作为一个跨平台的包装器来替换我正在移植到linux的一些遗留代码

我的代码的基本实现如下所示:

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);
m_TxRxThread = Man().CreateThreadPtr(Priority, thread_name, 0,ThreadProcTxRx, this);
但是当我构建它的时候,我得到了这个错误

/usr/include/boost/bind/bind.hpp:253:35: error: invalid conversion from 'CEth*' to 'long unsigned int' [-fpermissive]
使用
-fpermissive
一切似乎都正常,但这对我来说毫无意义,我想知道我在这里做错了什么

提前谢谢

--编辑--

ThreadProcTxRx
是签名为

void CEth::ThreadProcTxRx(ul32 lpParam)
其中
ul32
typedef unsigned long

写下最后一句话,谚语中的灯泡就亮了。。。当然,这需要是一个
ul32。当错误指向此`时,我正在关注
ThreadProcTxRx

嗯。。。感谢裁判官要求澄清。如果你想在回答这个问题的话,我会相信你的

-允许的

将有关不符合代码的某些诊断从错误降级为警告。因此,使用-fppermission将允许编译一些不符合要求的代码

通过使用
-fppermissive
编译,您正在将代码中的一些错误降级为警告编译。你应该避免这样做


您的代码出现的问题是,您试图分配一个类型为
CEth*
unsigned long
。如果可能,您将需要
static\u cast
返回到
无符号长
,或者检查返回类型是否正确。

什么是
ThreadProcTxRx
?看起来它需要一个
无符号长
参数,但您正在向它传递一个指向
CEth
的指针。请发一封电子邮件。