c++ - OGG Vorbis : Defined, 但未使用 - 如何抑制?

标签 c++ c openal ogg vorbis

我在学校有一个小组项目(3D FPS 游戏),我使用 C++ 中的 OpenAL 和 OGG Vorbis 对音频进行编程。我们的编译器设置为警告我们已定义但未使用的变量,结果证明这是 Vorbis 的问题。当我编译我们的应用程序时,我得到了这个:

[  8%] Building CXX object CMakeFiles/fps.dir/src/audio/Sound.cpp.o
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:82:21: warning: ‘OV_CALLBACKS_NOCLOSE’ defined but not used [-Wunused-variable]
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:89:21: warning: ‘OV_CALLBACKS_STREAMONLY’ defined but not used [-Wunused-variable]
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:96:21: warning: ‘OV_CALLBACKS_STREAMONLY_NOCLOSE’ defined but not used [-Wunused-variable]
[  9%] Building CXX object CMakeFiles/fps.dir/src/audio/MenuAudioController.cpp.o
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:75:21: warning: ‘OV_CALLBACKS_DEFAULT’ defined but not used [-Wunused-variable]
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:82:21: warning: ‘OV_CALLBACKS_NOCLOSE’ defined but not used [-Wunused-variable]
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:89:21: warning: ‘OV_CALLBACKS_STREAMONLY’ defined but not used [-Wunused-variable]
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:96:21: warning: ‘OV_CALLBACKS_STREAMONLY_NOCLOSE’ defined but not used [-Wunused-variable]
[ 10%] Building CXX object CMakeFiles/fps.dir/src/audio/GameAudioController.cpp.o
In file included from /home/berzeger/FPS/FPS/trunk/game/src/audio/GameAudioController.cpp:1:0:
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:75:21: warning: ‘OV_CALLBACKS_DEFAULT’ defined but not used [-Wunused-variable]
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:82:21: warning: ‘OV_CALLBACKS_NOCLOSE’ defined but not used [-Wunused-variable]
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:89:21: warning: ‘OV_CALLBACKS_STREAMONLY’ defined but not used [-Wunused-variable]
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:96:21: warning: ‘OV_CALLBACKS_STREAMONLY_NOCLOSE’ defined but not used [-Wunused-variable]
[ 11%] Building CXX object CMakeFiles/fps.dir/src/audio/AudioController.cpp.o
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:75:21: warning: ‘OV_CALLBACKS_DEFAULT’ defined but not used [-Wunused-variable]
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:82:21: warning: ‘OV_CALLBACKS_NOCLOSE’ defined but not used [-Wunused-variable]
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:89:21: warning: ‘OV_CALLBACKS_STREAMONLY’ defined but not used [-Wunused-variable]
/home/berzeger/FPS/FPS/trunk/game/src/audio/../../include/vorbis/vorbisfile.h:96:21: warning: ‘OV_CALLBACKS_STREAMONLY_NOCLOSE’ defined but not used [-Wunused-variable]

等等。你可以看到这是一团糟,重要的东西很容易丢失。

我似乎无法找到抑制 vorbis 未使用变量的方法。我试过了

#define OV_EXCLUDE_STATIC_CALLBACKS

但这会禁用所有 vorbis 定义,这不是我想要的。

有人可以帮忙吗?提前致谢!

最佳答案

就我个人而言,我会修改我的构建脚本以过滤掉那些特定的警告,但如果您不想这样做...

您可以创建一个包装器头文件,包括包装器文件而不是 vorbis 头文件,并在包装​​器头文件中使用问题变量,以便警告消失。假设它们是整数常量,这样的事情就足够了。

//File: myvorbisfile.h
#include "vorbisfile.h"

// Dummy function in the anonymous namespace 
// to suppress the unused variables
namespace
{
   int hide_unused_variables()
   {
     return 0
      + OV_CALLBACKS_NOCLOSE
      + OV_CALLBACKS_DEFAULT
      ... Fill in the rest ...
    }
}

关于c++ - OGG Vorbis : Defined, 但未使用 - 如何抑制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12526298/

相关文章:

c++ - 可以查询 OpenAL 设备它喜欢的频率和格式吗?

c++ - 加载 WAV 文件时出现 OpenAL 错误 40963

c++ - 从 OSx 上的自定义 url 打开 carbon c++ 程序

c++ - 我的复制构造函数失败..如何复制指向对象的指针

c++ - 我可以教 dynamic_cast<>() 新技巧吗?

c - 为什么可以在 C 中使用未定义的结构

c++ - 在多个容器中存储指向对象的指针

c - 递归获取obj文件进行链接

c - 数组中数字之间的升序排序

iphone - 如何使用特定时间瞬间的 openAL 命令播放声音文件(时间输入是 double 或 float )