6

私はemacsを使用して、コンパイルモードを使用してC ++プロジェクトをコンパイルnext-errorし、ソースの警告とエラーにジャンプするのが大好きです。next-errorただし、コンパイル出力の「Infileincludedfrom」の行のすべての#includeに移動するのは非常に面倒です。警告をスキップするために使用できることは知っていますがcompilation-skip-threshold、警告をスキップしたくありません。これらのインクルード行は警告として表示されます。

私には、これはコンパイルモードのバグのようです(これらは警告ではありません)が、このバグは「バグではない」としてクローズされました。

具体的には、次のような出力の場合:

In file included from /path/to/file1.h:linenum1:
In file included from /path/to/file2.h:linenum2:
In file included from /path/to/file3.h:linenum3:
/path/to/file4.h:linenum4:columnnum4: warning: you are bad at c++

next-error途中でファイル1から3に立ち寄るのではなく、file4.hに直接移動したいと思います。

ありがとう!

4

2 に答える 2

5

自分で試してみました。私の出力は次のようになっているため、gccのバージョンは異なるようです。

g++ test.cc 
In file included from file3.h:1:0,
                 from file2.h:1,
                 from file1.h:2,
                 from test.cc:2:
file4.h:1:2: warning: #warning "you are bad at c++" [-Wcpp]

しかし、私はまだ問題を見ています。どうやら、'gcc-include物事を壊すのは正規表現です。私の状況では、これらの「from」行はすべて正しく一致しますが、最後の行は一致します。問題は、それがコロンで終わっていることであり、これはどういうわけかそれを警告にします。私は今、そのような一致するターゲットがどのようなgcc出力メッセージを実行できるかを確認するのが少し怠惰です(理由があるはずですよね?)ので、質問に答えます:

;; This element is what controls the matching behaviour: according to
;; `compilation-error-regexp-alist` doc, it means if subexpression 4 of the
;; regexp matches, it's a warning, if subexpression 5 matches, it's an info.
(nth 5 (assoc 'gcc-include compilation-error-regexp-alist-alist))
(4 . 5)

;; We could try and tinker with the regexp, but it's simpler to just set it as
;; "always match as info".
(setf (nth 5 (assoc 'gcc-include compilation-error-regexp-alist-alist)) 0)

このスニペットは、コンパイルモードで最後の「from」行が警告として強調表示されないようにしました。

于 2013-03-19T03:08:06.523 に答える
2

を構成しcompilation-skip-thresholdます。

于 2013-03-19T13:23:37.477 に答える