外部ライブラリヘッダーのgccコンパイラの退屈なエラーを無視する方法

StackOverflow https://stackoverflow.com/questions/172484

質問

最近、クロスプラットフォームコードをクリーンアップするために、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
役に立ちましたか?

解決

ヘッダーを修正し、ffmpegにパッチを提出できます。 -pedantic との互換性は価値のある目標なので、特に末尾のコンマなどを削除するだけの場合は、彼らがそれを考慮すると確信しています。

他のヒント

gccで-Wsystem-headersオプションを使用すると、通常は表示されないシステムヘッダーに関連する警告メッセージが出力されます。ただし、gccでこれらのファイルを基本的にシステムヘッダーとして扱うようにしたいので、&quot; -isystem / usr / local / ffmpeg&quot;を渡してみてください。 (またはそのパッケージをインストールした場所)で、これらのディレクトリに含まれるファイルからのエラーもgccに無視させる。

これらの警告の送信を停止するようにgccに指示する方法がわかりません。ただし、llvm-gcc(または単にgcc)-pedantic 2&gt;&amp; 1 | grep -v&quot; / usr /&quot;

のようなものを使用すると、サードパーティの警告をハックして削除できます。

私の頭に浮かぶ1つのアイデア(このために「すぐに使える」パラメーターがあるかどうかわからない):

コンパイラの出力を取得するスクリプトを準備し、特定のリストにないヘッダー( your ヘッダー)を含むすべての行を削除します。

この方法でそれを行うのはそれほど難しくないはずです。

現時点では、GCCに一部のヘッダーについてだけ注意を喚起するよう指示することはできません。機能として提案するかもしれませんが、理想的には誰もが独創的であるので抵抗されると思います。

できることは、自分でヘッダーを修正し、パッチを生成してから、ライブラリをアップグレードする場合、そのパッチを新しいバージョンのヘッダーに適用することです。

パッチを採用することを期待してffmpegにもパッチを送信しますが、どちらの方法でも、受け入れなくてもカバーされます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top