我最近在 make gcc 编译选项中添加了 -pedantic 和 -pedantic-errors 以帮助清理我的跨平台代码。一切都很好,直到它在外部包含的头文件中发现错误。有没有办法在外部头文件 IE 中关闭此错误检查:
继续检查包含的文件,如下所示:
#include "myheader.h"
停止检查像这样的包含文件:
#include <externalheader.h>
以下是我收到的错误:
g++ -Wall -Wextra -Wno-long-long -Wno-unused-parameter -pedantic --pedantic-errors
-O3 -D_FILE_OFFSET_BITS=64 -DMINGW -I"freetype/include" -I"jpeg" -I"lpng128" -I"zlib"
-I"mysql/include" -I"ffmpeg/libswscale" -I"ffmpeg/libavformat" -I"ffmpeg/libavcodec"
-I"ffmpeg/libavutil" -o omingwd/kguimovie.o -c kguimovie.cpp
In file included from ffmpeg/libavutil/avutil.h:41,
from ffmpeg/libavcodec/avcodec.h:30,
from kguimovie.cpp:44:
ffmpeg/libavutil/mathematics.h:32: error: comma at end of enumerator list
In file included from ffmpeg/libavcodec/avcodec.h:30,
from kguimovie.cpp:44:
ffmpeg/libavutil/avutil.h:110: error: comma at end of enumerator list
In file included from kguimovie.cpp:44:
ffmpeg/libavcodec/avcodec.h:277: error: comma at end of enumerator list
ffmpeg/libavcodec/avcodec.h:303: error: comma at end of enumerator list
ffmpeg/libavcodec/avcodec.h:334: error: comma at end of enumerator list
ffmpeg/libavcodec/avcodec.h:345: error: comma at end of enumerator list
ffmpeg/libavcodec/avcodec.h:2249: warning: `ImgReSampleContext' is deprecated
(declared at ffmpeg/libavcodec/avcodec.h:2243)
ffmpeg/libavcodec/avcodec.h:2259: warning: `ImgReSampleContext' is deprecated
(declared at ffmpeg/libavcodec/avcodec.h:2243)
In file included from kguimovie.cpp:45:
ffmpeg/libavformat/avformat.h:262: error: comma at end of enumerator list
In file included from ffmpeg/libavformat/rtsp.h:26,
from ffmpeg/libavformat/avformat.h:465,
from kguimovie.cpp:45:
ffmpeg/libavformat/rtspcodes.h:38: error: comma at end of enumerator list
In file included from ffmpeg/libavformat/avformat.h:465,
from kguimovie.cpp:45:
ffmpeg/libavformat/rtsp.h:32: error: comma at end of enumerator list
ffmpeg/libavformat/rtsp.h:69: error: comma at end of enumerator list
最佳答案
将 -Wsystem-headers 选项与 gcc 一起使用将打印与系统 header 相关联的警告消息,这些消息通常被抑制。但是,您希望 gcc 基本上将这些文件视为系统头文件,因此您可以尝试传递“-isystem/usr/local/ffmpeg”(或安装该软件包的任何位置)以使 gcc 忽略包含在这些目录也是如此。
关于gcc - 如何忽略外部库头文件中的 gcc 编译器迂腐错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/172484/