本文介绍了错误:':: QueueUserWorkItem'尚未声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我举了一个如何从创建win服务的例子。尝试在Codelite中编译它并将其与wxidgets结合使用。最后一个问题是:

ThreadPool.h:57:14:错误:'':: QueueUserWorkItem''尚未声明

有谁知道如何解决这个问题?

Hi, i took an example of how to create win service from here and I''am trying to compile it in Codelite and combine it with wxidgets. And the very last problem is:
ThreadPool.h:57:14: error: ''::QueueUserWorkItem'' has not been declared
Does anybody know how to solve this?

class CThreadPool
{
public:

    template <typename T>
    static void QueueUserWorkItem(void (T::*function)(void),
        T *object, ULONG flags = WT_EXECUTELONGFUNCTION)
    {
        typedef std::pair<void (T::*)(), T *> CallbackType;
        std::auto_ptr<CallbackType> p(new CallbackType(function, object));

        if ( ::QueueUserWorkItem(ThreadProc<T>, p.get(), flags))
        {
            // The ThreadProc now has the responsibility of deleting the pair.
            p.release();
        }
        else
        {
            throw GetLastError();
        }
    }

private:

    template <typename T>
    static DWORD WINAPI ThreadProc(PVOID context)
    {
        typedef std::pair<void (T::*)(), T *> CallbackType;

        std::auto_ptr<CallbackType> p(static_cast<CallbackType *>(context));

        (p->second->*p->first)();
        return 0;
    }
};

推荐答案


这篇关于错误:':: QueueUserWorkItem'尚未声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 15:20