当我编译我的项目时,我得到了这个错误.
C:\src\libs\nvrtpaudio\FileRtpSource.
cpp(61) : error C3861: 'timeBeginPeriod': identifier not found
C:\src\libs\nvrtpaudio\FileRtpSource.
cpp(71) : error C3861: 'timeEndPeriod': identifier not found
gmake[5]: *** [_out/win7_x86_debug/FileRtpSource.obj] Error 2
Run Code Online (Sandbox Code Playgroud)
我包括windows.h但这个错误仍然存在.有谁知道如何解决这个问题?
MSDN 说:
标题:Mmsystem.h(包括Windows.h)
所以你应该包含"windows.h"并且没问题,但是MSDN没有说的是这假设你没有WIN32_LEAN_AND_MEAN定义,当定义时,这也可以是从模板创建的项目的情况 -驱逐你需要的"mmsystem.h".
因此,您必须确保WIN32_LEAN_AND_MEAN在项目中没有,或者直接包含:
#include "stdafx.h"
#include <mmsystem.h> // <<--- Here we go
#pragma comment(lib, "winmm.lib")
int _tmain(int argc, _TCHAR* argv[])
{
timeBeginPeriod(0);
return 0;
}
Run Code Online (Sandbox Code Playgroud)