a space is required between consecutive right angle bracketsを解決したい。

VScodeを用いてC++の環境構築をしています。
windowsからMacに乗り換えたので一から環境構築を再び始めたが、どうもうまくプログラムが実行できません。

C++

#include <bits/stdc++.h>using namespace std;#define rep(i,a,b) for(int i=a;i<b;i++)#define rrep(i,a,b) for(int i=a;i>=b;i--)#define fore(i,a) for(auto &i:a)#define all(x) (x).begin(),(x).end()typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }using P = pair<int,int>;using Graph = vector<vector<int>>; int main() { int n,m,x,t,d; cin >> n >> m >> x >> t >> d; if( m >= x ) cout << t << endl; else{ cout << t - d*(x - m) << endl; } return 0;}

のコードにおいて

using Graph = vector<vector<int>>;

に、a space is required between consecutive right angle bracketsとエラーメッセージが出る。

また、"pair"と"vector"に対し、alias declarations are a c++11 extensionの警告も出る。

現状

ビルドとデバックがうまく処理されない。
code runnerを用いようとしたが、違うフォルダ内の実行ファイルにうまく利用できない。

✔️<bits/stdc++.h>のパスは通っている状態。
✔️gcc, homebrew, code runner,CodeLLDB インストール済み。

.jsonのファイルと実行ファイルは同じディレクトリ、異なるフォルダ内にある。

実現したいこと

エラーを解決しatcoderで解いたプログラムを実行とデバッグ、数値を代入したら計算結果がきちんと出力される。

setting.json

C++

{"clang.executable": "clang++", "code-runner.runInTerminal": true, "clang.cxxflags": [ "-std=c++14" ], "code-runner.executorMap": { "javascript": "node", "java": "cd $dir && javac $fileName && java $fileNameWithoutExt", "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", "cpp": "cd $dir && g++ -O2 -std=c++14 $fileName && ./a.out" }, "[cpp]": { "editor.defaultFormatter": "ms-vscode.cpptools" }}

⚠️なぜだかこのコードの1行目と3行目の
"clang.executable": "clang++",
"clang.cxxflags": ["-std=c++14"],
が他より薄く表示されている。

c_cpp_properties.json

C++

{ "configurations": [ { "name": "Mac", "includePath": [ "${workspaceFolder}/**", "/usr/local/include/bits/*" ], "defines": [], "macFrameworkPath": [ "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks" ], "compilerPath": "/opt/homebrew/bin/g++-11", "cStandard": "c17", "cppStandard": "c++17", "intelliSenseMode": "macos-clang-arm64" } ], "version": 4}

launch.json

C++

{ "version": "0.2.0", "configurations": [ { "name": "(lldb) Launch", "type": "lldb", "request": "launch", "program": "${workspaceFolder}/a.out", "args": [], "cwd": "${workspaceFolder}", "preLaunchTask": "Build with gcc" } ]}

tasks.jsonのコード

C++

{ "version": "2.0.0", "tasks": [ { "label": "Build with gcc", "type": "shell", "command": "g++", "args": [ "-std=c++17", "-gdwarf-3", "atcoder.cpp", "-o", "a.out", "--debug" ], "group": "build" }, { "type": "cppbuild", "label": "C/C++: clang++ アクティブなファイルのビルド", "command": "/usr/bin/clang++", "args": [ "-fdiagnostics-color=always", "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "detail": "デバッガーによって生成されたタスク。" } ]}

[主に参考にした文献]
https://qiita.com/dhirabayashi/items/fc4327b1771d07502adc-
https://qiita.com/EngTks/items/ffa2a7b4d264e7a052c6

コメントを投稿

0 コメント