c++ - pthread_cleanup_pop error on Windows- make it compilable -
code:
void clean(void *message) { cout<<"exiting "<<(char*)message<<endl; } void *func2(void* arg) { char *message = "func2"; pthread_cleanup_push(clean,(void*)message); int status; int count=0; pthread_setcancelstate(pthread_cancel_enable,&status); for(;;){ if(count%3467==0) { sleep(3); pthread_testcancel(); } else if(count%67==0) { cout<<"func 2 running"<<endl; } else {} count++; } pthread_cleanup_pop(0);//error pointing here }
when try compile , getting error
cancel.cpp:45:5: error: second operand conditional operator of type 'v oid', third operand neither throw-expression nor of type 'void' pthread_cleanup_pop(cleanup_pop_arg);
i not able find what's problem code. compiled g++ file.cpp -pthread
, windows 8, cygwin 64.
how make code compile successfully?
edit:
after preprocessing how look.
void *func2(void* arg) { char *message = "func2"; { const _pthread_cleanup _pthread_cup = {(clean), ((void*)message), *pthread_getclean()}; __sync_synchronize(); *pthread_getclean() = (_pthread_cleanup *) &_pthread_cup; __sync_synchronize(); int status; int count=0; pthread_setcancelstate(0x01,&status); for(;;){ if(count%3467==0) { sleep(3); pthread_testcancel(); } else if(count%67==0) { cout<<"func 2 running"<<endl; } else {} count++; } (*pthread_getclean() = _pthread_cup.next, (cleanup_pop_arg?_pthread_cup.func((pthread_once_t *)_pthread_cup.arg):0));}; }
Comments
Post a Comment