VC编译错误:'waveformat_tag' : 'struct' type redefinition
错误信息: : error C2011: 'waveformat_tag' : 'struct' type redefinition
: error C2011: 'pcmwaveformat_tag' : 'struct' type redefinition
: error C2061: syntax error : identifier 'LPCWAVEFORMATEX'
: error C2061: syntax error : identifier 'LPCWAVEFORMATEX'
解决方法:
这是头文件包含顺序不正确所致。原先的文件包含顺序为:
#include <mmreg.h>
#include <mmsystem.h>
#include <msacm.h>
可以看到,mmreg.h文件中有如下定义:
#ifndef WAVE_FORMAT_PCM
typedef struct waveformat_tag ××××
而WAVE_FORMAT_PCM在mmsystem.h中有定义,但是在#include <mmreg.h>之前,WAVE_FORMAT_PCM还是没有被定义,所以,typedef struct waveformat_tag ××××语句生效,之后mmsystem.h中再次定义waveformat_tag,于是出现重复定义。
正确的包含顺序是:
#include <mmsystem.h>
#include <mmreg.h>
#include <msacm.h>
(包含静态库)
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "Msacm32.lib")
本文介绍了VC编译过程中出现的'waveformat_tag':'struct'typeredefinition错误原因及解决办法。该错误通常由头文件包含顺序不当导致。通过调整包含顺序可以避免结构体重复定义的问题。

被折叠的 条评论
为什么被折叠?



