InitializeCriticalSectionAndSpinCount identifier not found

来源:互联网 发布:自动配色软件 编辑:程序博客网 时间:2024/06/05 20:23

error C3861 InitializeCriticalSectionAndSpinCount identifier not found

在使用Visual Studio编译一个文件时,发现一个奇怪的编译错误:ERROR C3861,提示没有找到InitializeCriticalSectionAndSpinCount。难道拼写错了?但是没有啊。提示信息如下:

.\Deadlock.cpp(28) : error C3861: 'InitializeCriticalSectionAndSpinCount': identifier not found.\Deadlock.cpp(32) : error C3861: 'InitializeCriticalSectionAndSpinCount': identifier not found

去MSDN一查,看到了一个提示:

To compile an application that uses this function, define _WIN32_WINNT as 0x0403 or later. For more information, see Using the Windows Headers.

于是在头文件下面包含了一条宏定义指令:

#define _WIN32_WINNT 0x0403

问题还是没有解决,编译错误继续存在。后来想是不是要把这句代码放到windows.h的前面呢?于是把这条语句放到文件的开头就好了。
【其他情况】
因为上面的情况是单独编译一个源文件,没有stdafx.h。网上的情况是工程的话,可以改一下这个头文件:
If you’ve got stdafx.h, try removing the following line if you have it.

#define WIN32_LEAN_AND_MEAN

Also note that MSDN says: “To compile an application that uses this function, define _WIN32_WINNT as 0×0403 or later”

0 0
原创粉丝点击