InitializeCriticalSectionAndSpinCount identifier not found

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值