Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.
1696 Discussions

Problem in compiling Threadpool functions like QueUserWorkItem()

coolsandyforyou
Beginner
375 Views
I am trying to multi thread my video coded application using threadpool functions.I am trying small examples with these functions. But i could not compile when i use those functions can some body help me tegarding this..
#include
#include
#include
#define MAX_THREADS 6
DWORD WINAPI lprint(LPVOID p);
struct node
{
int a,b;
};
typedef struct node* NODEPTR;
void main()
{
NODEPTR ptr[MAX_THREADS];
DWORD th[MAX_THREADS];
BOOL hth[MAX_THREADS];
int i;
for(i=0;i
{
ptr=(NODEPTR)malloc(sizeof(NODEPTR));
ptr->a=i;
ptr->b=i*1000;
//hth=CreateThread(NULL,0,lprint,ptr,0,&th);
hth=QueueUserWorkItem(lprint,ptr,WT_EXECUTEDEFAULT);
//WT_EXECUTEINIOTHREAD
}
WaitForMultipleObjects(MAX_THREADS, hth , TRUE, INFINITE);
for(i=0;i
{
CloseHandle(hth);
}
getch();
}
DWORD WINAPI lprint(LPVOID p)
{
NODEPTR s1=(NODEPTR) p;
printf("%d %d\\n",s1->a,s1->b);
return 0;
}
0 Kudos
6 Replies
Dmitry_Vyukov
Valued Contributor I
375 Views
Do you define _WIN32_WINNT as at least 0x0500?
What error do you get?
0 Kudos
coolsandyforyou
Beginner
375 Views
error C3861: 'QueueUserWorkItem': identifier not found
even after defining i got this above error.
i have included only windows.h ,do i need to include other header files,and my code is in C,can i use this function in C code?
pls reply..
thanks in advance
0 Kudos
Dmitry_Vyukov
Valued Contributor I
375 Views
Don't you use MS Visual Studio 2003? It looks like you have substantially outdated Platform SDK...
Do you have definition of QueueUserWorkItem() in winbase.h?
0 Kudos
coolsandyforyou
Beginner
375 Views
I m using visual studio 2008.
I have definition of QueueUserWorkItem() in winbase.h(include dir of platform SDK)
should i use MS VS 2003? cant i use 2008?
how to update the new platformSDK?
0 Kudos
Dmitry_Vyukov
Valued Contributor I
375 Views
Humm... well, the following program compiles and links successfully on my MSVC2008

// main.c
#include "windows.h"

DWORD CALLBACK func(void* p)
{
return 0;
}

int main()
{
QueueUserWorkItem(func, 0, 0);
return 0;
}

0 Kudos
coolsandyforyou
Beginner
375 Views
i have included platformSDK include folder,which have WInBase.h,and Queuserworkitem is defined in it.still the same error in my project..im using older version of platform sdk..is this the reason..or do i have to include any extra directories?
0 Kudos
Reply