简体   繁体   English

pthread.h头问题

[英]pthread.h header problem

hi I'm doing porting from Linux to Visual C++ . 嗨,我正在从Linux移植到Visual C ++。 When I built the coding, it shows that VC ++ doesn't know this pthread.h header. 当我构建编码时,它表明VC ++不知道这个pthread.h头。 I can't comment it since there is a variable " pthread_mutex_t " in the code. 我无法评论它,因为代码中有一个变量“pthread_mutex_t”。 What should I do ? 我该怎么办 ? Does VC ++ has equivalent header for it? VC ++是否有相应的标题?

Kevin 凯文

There is a pthreads implementation for Windows, it's called pthread-w32: 有一个针对Windows的pthreads实现,它叫做pthread-w32:

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

I don't think you'll find pthreads on windows unless you're using cygwin or something similar. 除非你使用cygwin或类似的东西,否则我认为你不会在Windows上找到pthreads。 Try the windows specific CriticalSection: http://msdn.microsoft.com/en-us/library/ms682530(v=vs.85).aspx 尝试Windows特定的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和unix的boost: http//www.boost.org/doc/libs/release/doc/html/thread/synchronization.html

Windows has no native support for pthreads. Windows对pthread没有本机支持。 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. 如果你想在没有重大代码更改的情况下在Windows上使用pthread,你可能想要查看Cygwin或其他无数的其他pthread端口。

That said, in my opinion your best move is to use an cross-platform threading library to begin with, such as boost . 也就是说,在我看来,最好的举措是使用跨平台的线程库,例如boost thread . 线程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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