16

最近、クロスプラットフォーム コードのクリーンアップを支援するために、make GCC コンパイル オプションに-pedanticおよび-pedantic-errorsを追加しました。外部インクルード ヘッダー ファイルにエラーが見つかるまでは、すべて問題ありませんでした。外部ヘッダー ファイルでこのエラー チェックをオフにする方法はありますか。

次のように含まれているファイルをチェックし続けます。

#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
4

5 に答える 5

34

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

于 2008-10-05T19:49:06.833 に答える
1

これらの警告の発行を停止するように GCC に指示する方法がわかりません。llvm-gccただし、サードパーティの警告を(または単に gcc)のようなものでハックして削除できます-pedantic 2>&1|grep -v "/usr/"

于 2009-04-17T16:33:35.360 に答える
0

私の頭に浮かぶ1つのアイデア(これに「すぐに使える」パラメーターがあるかどうかはわかりません):

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

このようにするのはそれほど難しいことではないはずです。

于 2008-10-05T19:40:55.150 に答える
-4

ヘッダーを修正してFFmpegにパッチを送信できます。との互換性-pedanticは価値のある目標なので、特に末尾のコンマなどを削除するだけの場合は、検討するでしょう。

于 2008-10-05T19:53:27.653 に答える