10

ドキュメントを読みましたが、さらに混乱しました。
コンパイラによって生成された次のエラーがあります。

          rot;
          ^
"cpp\c1.cpp", line 13: error(114): identifier
          "rot" is undefined


1 error detected in the compilation of "c1.cpp".

エラー行が指定されている行を検出する方法は知っていますが、エラーリストに余分な役に立たない情報が大量に表示され、エラーメッセージが2行に分割されているため、マージすることをお勧めします.

私の開始エラーフォーマットは次のとおりです。

:set efm=\"%f\"\\,\ line\ %l:\ error(%n):\ %m

私たちはそれに取り組んでいるので、常にmakeを実行することに頼らずにefmをテストする簡単な方法はありますか?

4

1 に答える 1

28

まず、デバッグについて説明します。残念ながら、特に簡単な方法はありませんが、make を実行して出力をファイルに出力し、次に:

:let &makeprg="cat ~/outputfile.log"
:make

エラーフォーマットの作成に関しては、少し試行錯誤が必要です。複数行のメッセージには %A、%C、および %Z を使用でき、%-G を使用して内容を無視できます。順序は非常に重要です。%C または %Z が %A の前に来る場合があることに注意してください。あなたの場合、以下のefmでどこかに到達できるかもしれません。すべてのスペースや引用符をエスケープする必要がなく、徐々に構築できるため、set ではなくlet &efm =andを使用する傾向があります。let &efm .=また、はるかに読みやすくなっています。

" Start of the multi-line error message (%A),
" %p^ means a string of spaces and then a ^ to
" get the column number
let &efm  = '%A%p^' . ','
" Next is the main bit: continuation of the error line (%C)
" followed by the filename in quotes, a comma (\,)
" then the rest of the details
let &efm .= '%C"%f"\, line %l: error(%n): %m' . ','
" Next is the last line of the error message, any number
" of spaces (' %#': equivalent to ' *') followed by a bit
" more error message
let &efm .= '%Z %#%m' . ','
" This just ignores any other lines (must be last!)
let &efm .= '%-G%.%#'
于 2009-10-06T18:07:51.503 に答える