c - minGW 中的线程 C 程序

标签 c mingw

我正在创建一个程序,当某个链接断开时,该程序会拦截所有数据包。我需要将嗅探器和链接检查器实现为线程。但 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/

相关文章:

将 ifaddr 的地址复制到 ifreq 结构

c - 使用 fscanf() 在 C 中进行加法和减法

c++ - Netbeans C++ 尝试 make.exe 的相对路径

fortran - 测试 float 相等

java - 使用 MinGW 为 Windows 构建一个 Linux 库

c - MinGW找不到源文件

c++ - 在启动过程中程序以代码 0xc0000139 退出

c - Applescript shell 脚本无法写入文件?

c - 使用 Pango 将文本呈现为使用 FreeType 字体的图像的简单示例是什么?

c - 执行与我的 C 程序不同的程序