[英]OGG Vorbis: Defined, but not used - how to suppress?
我在学校有一个小组项目(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 ...
}
}
好的,我想我已经找到解决方案了。 我们已将头文件复制到我们的应用程序目录中,因此我以这种方式包含了vorbisfile.h:
#include "../../include/vorbis/vorbisfile.h"
当我将此行更改为:
#include <vorbis/vorbisfile.h>
警告消失了。 不知道为什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.