Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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?
C++
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;
    }
};
Posted

1 solution

In the immortal words of Microsoft:
"To compile an application that uses ths function, define _WIN32_WINNT as 0x0500 or later."

Obviously you also have to #include <windows.h> but I'm guessing you already did that.

You don't need the scope resolution operator :: In front of QueueUserWorkItem but I can't see that it would do any harm.
 
Share this answer
 
v2
Comments
lliame 13-Apr-13 15:05pm    
Nice thanks a lot. That did the trick ;)
In mingw-4.7.1\include\windef.h it was defined as 0x0400. So I defined it before inculding windows.h as 0x0500 and it worked.
Thanks a lot.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900