我正在创建一个程序,当某个链接断开时,该程序会拦截所有数据包。我需要将嗅探器和链接检查器实现为线程。但 minGW 没有 pthreads。
如何在 minGW 中实现线程?
编辑:答案
http://www.codeproject.com/KB/threads/sync.aspx
Vivek Goel 引导我做到了这一点 (_beginthread)。这两个示例都在 Code::blocks/minGW 上编译!
最佳答案
MinGW 不提供完整的 POSIX 模型。如果您想要标准包中的线程,则必须使用 Windows 品种。
它在 MinGW 上声明 main page :
MinGW compilers provide access to the functionality of the Microsoft C runtime and some language-specific runtimes. MinGW, being Minimalist, does not, and never will, attempt to provide a POSIX runtime environment for POSIX application deployment on MS-Windows. If you want POSIX application deployment on this platform, please consider Cygwin instead.
Cygwin 确实有 pthreads 支持,因为它提供了 Cygwin DLL(一个模拟层),而 MinGW 更多的是用于 Windows 处理方式的 gcc。
或者,如果 Cygwin 不是一个选项,您可以查看 Pthreads/Win32它声称与 MinGW 合作。
关于c - minGW 中的线程 C 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48952035/