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

标签 gcc compiler-construction compiler-errors

我最近在 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/

相关文章:

gcc - 扩展#define之类的宏后,如何运行GCC预处理程序以获取代码?

c - 使用 cygwin gcc 时出现 typedef 定义错误

compiler-construction - VHDL编译器退出错误

c# - 有趣的代码片段

c++ - 链接到 boost_thread 的问题

gcc - 在 PIC32 (MIPS32) 上运行的 C++

c - 如何将c++程序编译成共享库,并从c程序加载它?

java - Java 编译器是否有非类型删除的泛型扩展可用作第 3 方编译器扩展?

compiler-errors - 如何定义 Prop 的类型

android - 编译Android