【发布时间】:2015-10-23 17:55:15
【问题描述】:
我构建了一个多语言软件图像处理程序,并使其与 Mac OS X 和 Ubuntu 的二进制文件一起普遍可用。这些二进制文件已在各自的操作系统上进行了测试,并且一切正常。我最近还尝试为 Windows(64 位)发布二进制文件,但是当我创建共享库 (dll) 文件时,GCC(通过 MinGW-w64)编译器给了我一个 C 程序的警告。这在 Mac OS X 或 Ubuntu 中没有发生。以下是 C 文件中的警告和相应的代码行:
warning: passing argument 3 of '_beginthreadex' from incompatible pointer type [enabled by default]
第 464 行:
ThreadList[i] = (HANDLE)_beginthreadex( NULL, 0, &ThreadFunc, &ThreadArgs[i] , 0, NULL );
第二个陌生人警告:
c:\mingw\x86_64-w64-mingw32\include\process.h:31:29: note:
expected 'unsigned int <*><void *>' but argument is of type 'void * <*><void *>'
_CRTIMP uintptr_t _cdecl _beginthreadex<void *_Security,unsigned _Stacksize,unsigned <_stdcall *_StartAddress> <void *>,void *_ArgList,unsigned _InitFlag,unsigned *_ThrdAddr >;
第 34 行:
#include <process.h>
这属于这个更大的代码块:
/* Multithreading stuff*/
#ifdef _WIN32
#include <windows.h>
#include <process.h>
#else
#include <pthread.h>
#endif
#include <stdbool.h>
问题似乎来自#include <process.h>,因为对于 Mac OS X 和 Ubuntu,使用了 #include <pthread.h>。任何帮助解决这个问题?完整的 C 程序是 here 。
【问题讨论】:
-
这是一条警告信息,可能是无害的。如果您的程序在运行时意外退出,那么很可能是因为其他原因。
-
我在没有任何警告的情况下编译的另一个 C 程序作为该软件的一部分成功运行。该软件的所有其他组件都运行良好。在 Ubuntu 和 Mac OS X 上,整个软件运行得非常好。剩下这个 C 文件和警告消息。我可以从打印语句中看到程序在这个特定的 C 文件期间退出。这不可能是巧合。
-
在我看来,这就像一条红鲱鱼。但你是专家。
-
警告信息来自
#include <process.h>。这在 MacOS X 和 Windows 版本中没有使用。这就是我怀疑的原因。 -
默认情况下,您必须单击左上角菜单并选择“编辑>标记”以复制出cmd窗口。您可以在属性中打开“快速编辑模式”来更改默认值
标签: c windows multithreading gcc mingw-w64