如何忽略外部库头中的gcc编译器迂腐错误?

KPe*_*xEA 16 compiler-construction gcc compiler-errors

我最近在make gcc编译选项中添加了-pedantic和-pedantic-errors来帮助清理我的跨平台代码.一切都很好,直到它在外部包含的头文件中发现错误.有没有办法关闭外部头文件IE中的错误检查:

继续检查包含的文件如下:

#include "myheader.h"
Run Code Online (Sandbox Code Playgroud)

停止检查包含这样的包含文件:

#include <externalheader.h>
Run Code Online (Sandbox Code Playgroud)

以下是我得到的错误:

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
Run Code Online (Sandbox Code Playgroud)

Nik*_*man 34

在gcc中使用-Wsystem-headers选项将打印与系统头相关联的警告消息,这些消息通常被抑制.但是,您希望gcc基本上将这些文件视为系统头文件,因此您可以尝试传递"-isystem/usr/local/ffmpeg"(或安装该软件包的任何地方)以使gcc忽略包含在文件中的文件中的错误这些目录也是如此.


小智 -4

您可以修复标头并向FFmpeg提交补丁;兼容性-pedantic是一个有价值的目标,所以我相信他们会考虑它,特别是如果它只涉及删除尾随逗号等。

  • 这实际上并不能回答问题。 (11认同)