简体   繁体   English

使用g ++ 4.6.1尝试包含xaudio2.h时,出现许多C ++编译错误

[英]Using g++ 4.6.1 I get many C++ compile errors when trying to include xaudio2.h

I have a c++ Windows app that compiles fine using Visual Studio 2010. I also wanted to have the ability to compile it using MinGW (on a Windows7-64 PC). 我有一个c ++ Windows应用程序,可以使用Visual Studio 2010很好地进行编译。我还希望能够使用MinGW(在Windows7-64 PC上)对其进行编译。 When g++ processes the xaudio2.h header file I get the errors listed below. 当g ++处理xaudio2.h头文件时,出现以下错误。 Does anyone know of a fix aside from manually hacking the include file. 除了手动修改包含文件之外,没有人知道修复方法。

SDKS/DX/Include/xaudio2.h:51:1: error: pasting "5a508685" and "-" does not give
a valid preprocessing token
SDKS/DX/Include/xaudio2.h:51:1: error: pasting "-" and "a254" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:51:1: error: pasting "a254" and "-" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:51:1: error: pasting "-" and "4fba" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:51:1: error: pasting "4fba" and "-" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:51:1: error: pasting "-" and "9b" does not give a vali
d preprocessing token
SDKS/DX/Include/xaudio2.h:51:1: error: pasting "9b82" and "-" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:51:1: error: pasting "-" and "9a" does not give a vali
d preprocessing token
SDKS/DX/Include/xaudio2.h:52:1: error: pasting "db05ea35" and "-" does not give
a valid preprocessing token
SDKS/DX/Include/xaudio2.h:52:1: error: pasting "-" and "0329" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:52:1: error: pasting "0329" and "-" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:52:1: error: pasting "-" and "4d4b" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:52:1: error: pasting "4d4b" and "-" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:52:1: error: pasting "-" and "a5" does not give a vali
d preprocessing token
SDKS/DX/Include/xaudio2.h:52:1: error: pasting "a53a" and "-" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:52:1: error: pasting "-" and "6d" does not give a vali
d preprocessing token
SDKS/DX/Include/xaudio2.h:53:1: error: pasting "8bcf1f58" and "-" does not give
a valid preprocessing token
SDKS/DX/Include/xaudio2.h:53:1: error: pasting "-" and "9fe7" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:53:1: error: pasting "9fe7" and "-" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:53:1: error: pasting "-" and "4583" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:53:1: error: pasting "4583" and "-" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:53:1: error: pasting "-" and "8a" does not give a vali
d preprocessing token
SDKS/DX/Include/xaudio2.h:53:1: error: pasting "8ac6" and "-" does not give a va
lid preprocessing token
SDKS/DX/Include/xaudio2.h:53:1: error: pasting "-" and "e2" does not give a vali
d preprocessing token
In file included from common/system.h:71:0,
                 from game.cpp:1:
SDKS/DX/Include/xaudio2.h:65:69: fatal error: sal.h: No such file or directory
compilation terminated.

Here are the lines in the xaudio2.h: 这是xaudio2.h中的行:

DEFINE_CLSID(XAudio2, 5a508685, a254, 4fba, 9b, 82, 9a, 24, b0, 03, 06, af);
DEFINE_CLSID(XAudio2_Debug, db05ea35, 0329, 4d4b, a5, 3a, 6d, ea, d0, 3d, 38, 52);
DEFINE_IID(IXAudio2, 8bcf1f58, 9fe7, 4583, 8a, c6, e2, ad, c4, 65, c8, bb);

and it looks like the defines are in comdecl.h as: 它看起来像在comdecl.h中的定义为:

#define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
            class DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) className; \
            EXTERN_C const GUID CLSID_##className

#define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
            interface DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) interfaceName; \
            EXTERN_C const GUID IID_##interfaceName

Found a trick that works. 找到了可行的技巧。 include XAudio2 as if from C, not C++. 包括XAudio2,就好像来自C而不是C ++。

#undef __cplusplus
#include <xaudio2.h>
#define __cplusplus

这可能有助于解释它的GCC串联

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试使用Rcpp编译c ++ 11时出现g ++错误 - g++ errors when trying to compile c++11 with Rcpp 试图编译我的C ++代码,无法识别g ++? - Trying to get my C++ code to compile, g++ not recognized? 使用G ++编译时出现以下错误 - Get the following errors when I compile with G++ 将Netbeans(C ++)与G ++一起使用时出现未定义的参考错误 - Undefined reference errors when using Netbeans (C++) with G++ 尝试使用R的g ++编译器编译C ++代码时出现“链接器输入文件”未使用的错误 - “linker input file” unused error when trying to compile C++ code using R's g++ compiler 我在尝试用 g++ 编译这个 C++ 程序时遇到了麻烦? - I'm having troubles trying to compile this C++ program with g++? “未定义的引用”使用“g++”编译 C++ 程序 - "undefined reference to" using 'g++' to compile a C++ program 使用命名空间时,C ++模板函数无法与g ++一起编译 - C++ Template function fails to compile with g++ when using namespace 我如何用openmp编译C ++? (在Windows 10中使用g ++) - How can i compile c++ with openmp? (using g++ in windows 10) 尝试使用g ++编译目标文件时出现“-std = c ++ 11:command not found”错误 - Got “-std=c++11: command not found” error when trying to compile a object file using g++
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM