2017-01-04 25 views
0

私はVSコードIDEで使用するVSコマンドラインコンパイラを設定しようとしています。私は例を読んで、問題なくGCCを使うことができますが、今でもVSコンパイラを使う必要があります。Visual Stadioのコマンドラインコンパイラ(CL.EXE)出力を正規表現でキャプチャする

私は1行の問題のマッチャーと複数の問題を試しました。しかし、VCコードは何もキャプチャしていないようです。ここで

は、コンパイラからのエラーと出力の例です:

regExprの式を使用
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.40629 for x86 
Copyright (C) Microsoft Corporation. All rights reserved. 
helloWorld.c 
..\Code\helloWorld.c(7) : error C2143: syntax error : missing ';' before '}' 

(.*\n){2,3}\S+(\d+)\W+:\s(\bwarning|error\b\s\w+):\s(\w+\s\w+)\s+:\s(.*)$ 

それは私が(:https://regex101.com/をここに私の仕事をチェックする)必要なすべての情報をキャプチャ

私はそれをVSコードのTasks.jsonファイルに入れても機能しません。

{ 
"version": "0.1.0", 
"command": "Build", 
"args": [ 
    "${fileBasename}" 
], 
"isShellCommand": true, 
"tasks": [ 
    { 
     "taskName": "Build", 
     // Make this the default build command. 
     "isBuildCommand": true, 
     // Show the output window only if unrecognized errors occur. 
     "showOutput": "always", 
     // No args 
     "args": [ 
      "all" 
     ], 
     // Use the standard less compilation problem matcher. 
     "problemMatcher": { 
      "owner": "cpp", 
      "fileLocation": [ 
       "relative", 
       "${workspaceRoot}" 
      ], 
      "pattern": { 
       "regexp": "(.*\n){2,3}\\S+(\\d+)\\W+:\\s(\bwarning|error\b\\s\\w+):\\s(\\w+\\s\\w+)\\s+:\\s(.*)$", 
       "file": 1, 
       "line": 2, 
       "severity": 3, 
       "code": 4, 
       "message": 5 
      } 
     } 
    } 
] 

}

誰もがどのようにコードIDE VSセットアップコマンドラインコンパイラVS使用するに知っていますか?どんな助けにも大いに感謝します

+0

である必要があります。テキスト出力ではなくcl.exeからの戻り値を使用する方がいいですか? https://msdn.microsoft.com/en-us/library/ebh0y918.aspx –

+0

IDEにエラーコードをハイライトさせたい場合は、問題のマッチャーを定義します。https://code.visualstudio.com/Docs/エディタ/タスク#define-a-problem-matcher – Zenn

答えて

0

/nologoフラグをコンパイラに追加することで、出力の最初の2行を避けることができます。だからあなたのtasks.jsonは:

"tasks": [ 
    { 
     "taskName": "Build", 
     "isBuildCommand": true, 
     "showOutput": "always", 
     "args": [ 
      "all" 
     ], 
     "problemMatcher": { 
      "owner": "cpp", 
      "severity": "info", // treat note as info 
      "fileLocation": "absolute", 
      "pattern": { 
       "regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error|note)\\s*(\\w+)?:\\s+(.*)$", 
       "file": 1, 
       "location": 2, 
       "severity": 3, 
       "code": 4, 
       "message": 5 
      } 
     } 
    } 
] 
関連する問題