在windows build上使用pthread.h

old*_*ice 9 c c++ pthreads

我有一个广泛使用pthread.h的代码库.在windows visual studio项目中,这显然不起作用,因为pthreads是一个unix实用程序.

我知道存在pthread-win32或类似的东西,但有没有办法让代码库使用它,而不替换所有的pthread代码?

编辑:我宁愿不必通过并替换所有的pthread调用.这是我的问题

Nov*_*kov 7

试试http://sourceware.org/pthreads-win32/.虽然我从未使用过那个特定的库,但我很幸运使用了POSIX API的一些Windows端口/抽象层.


bma*_*ies 5

I would recommend boost as a library that contains a platform-independent thread abstraction. I don't think you'll find any attempt to call the pthread functions themselves to be satisfying. It's also not very hard to map pthread to Win32 for yourself.

  • 对于拥有使用pthreads的现有代码库的人来说不是很有用,他们不希望重写线程代码.:) (4认同)