Saturday 15 September 2012

c++ - Undeclared identifier error message -



c++ - Undeclared identifier error message -

i got error message when calling createthread function.

#include "stdafx.h" #include "functions.h" #include <windows.h> int _tmain(int argc, _tchar* argv[]) { dword tida, tidb, tidc; handle task1, task2, task3; task1 = createthread(null, 0, (lpthread_start_routine) thread1, null, 0, &tida); task2 = createthread(null, 0, (lpthread_start_routine) thread2, null, 0, &tidb); task3 = createthread(null, 0, (lpthread_start_routine) thread3, null, 0, &tidc); setthreadpriority(task1, thread_priority_highest); setthreadpriority(task2, thread_priority_normal); setthreadpriority(task3, thread_priority_lowest); closehandle(task1); closehandle(task2); closehandle(task3); } void thread1() { printf("task#2 >>> started\n"); int *firstfunc = (new functions())->firstfunc(data::vectorinitialize(), data::matrixinitialize(), data::matrixinitialize()); sleep(3000); data::vectoroutput(firstfunc); printf("\ntask#2 >>> finished\n"); } void thread2() { printf("task#1 >>> started\n"); int **secondfunc = (new functions())->secondfunc(data::matrixinitialize(), data::matrixinitialize(), data::matrixinitialize(), data::matrixinitialize()); sleep(2000); data::matrixoutput(secondfunc); printf("\ntask#1 >>> finished\n"); } void thread3() { printf("task#3 >>> started\n"); int *thirdfunc = (new functions())->thirdfunction(data::matrixinitialize(), data::matrixinitialize(), data::vectorinitialize()); sleep(1000); data::vectoroutput(thirdfunc); printf("\ntask#3 >>> finished\n"); }

here error message:

error c2065: thread1: undeclared identifier error c2065: thread2: undeclared identifier error c2065: thread3: undeclared identifier

thread1 used before defined.

you can move thread1, thread2, thread3 function definitions above main

or can declare above main.

c++

No comments:

Post a Comment