简体   繁体   中英

pthread.h header problem

hi I'm doing porting from Linux to Visual C++ . When I built the coding, it shows that VC ++ doesn't know this pthread.h header. I can't comment it since there is a variable " pthread_mutex_t " in the code. What should I do ? Does VC ++ has equivalent header for it?

Kevin

There is a pthreads implementation for Windows, it's called pthread-w32:

http://sourceware.org/pthreads-win32/

I don't think you'll find pthreads on windows unless you're using cygwin or something similar. Try the windows specific CriticalSection: http://msdn.microsoft.com/en-us/library/ms682530(v=vs.85).aspx

Or use boost which should work on both windows and unix: http://www.boost.org/doc/libs/release/doc/html/thread/synchronization.html

Windows has no native support for pthreads. If you want to use pthreads on Windows without significant code changes, you may want to look into Cygwin or one of the myriad other pthread ports.

That said, in my opinion your best move is to use an cross-platform threading library to begin with, such as boost . thread .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM