Tou*_*mam 0 c++ visual-studio-code vscode-settings vscode-tasks
我试图从工作区中运行一个.cpp文件,但是给了我关于不添加c ++ 11 / higher标志的错误,但是我将它们添加到task.json中
错误
[Running] cd "c:\Users\Nuhash\Desktop\test\" && g++ main.cpp -o main && "c:\Users\Nuhash\Desktop\test\"main
main.cpp:8:1: error: expected unqualified-id before 'using'
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
^
main.cpp:10:1: error: expected unqualified-id before 'using'
using ordered_set_rev = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
^
main.cpp:12:1: error: expected unqualified-id before 'using'
using dijkstra = priority_queue<T, vector<T>, greater<T>>;
^
main.cpp:62:31: warning: variadic templates only available with -std=c++11 or -std=gnu++11
template <typename T, typename... Args>
^
main.cpp:63:52: warning: variadic templates only available with -std=c++11 or -std=gnu++11
void err(istream_iterator<string> it, T a, Args... args) {
Run Code Online (Sandbox Code Playgroud)
杰森
{
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "g++",
"args": [
"-g",
"-o",
"test",
"-std=c++14",
"main.cpp"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
错误信息:
[Running] cd "c:\Users\Nuhash\Desktop\test\" && g++ main.cpp -o main && "c:\Users\Nuhash\Desktop\test\"main
main.cpp:8:1: error: expected unqualified-id before 'using'
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
^
main.cpp:10:1: error: expected unqualified-id before 'using'
using ordered_set_rev = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
^
main.cpp:12:1: error: expected unqualified-id before 'using'
using dijkstra = priority_queue<T, vector<T>, greater<T>>;
^
main.cpp:62:31: warning: variadic templates only available with -std=c++11 or -std=gnu++11
template <typename T, typename... Args>
^
main.cpp:63:52: warning: variadic templates only available with -std=c++11 or -std=gnu++11
void err(istream_iterator<string> it, T a, Args... args) {
Run Code Online (Sandbox Code Playgroud)
c_cpp_properties:
{
"name": "Win32",
"includePath": [
"${workspaceFolder}"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"compilerPath": "F:\\Program Files (x86)\\CodeBlocks\\MinGW\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17"
}
Run Code Online (Sandbox Code Playgroud)
我添加了代码运行程序并将其添加到settings.json中似乎对我有用:D
"code-runner.runInTerminal": true,
"code-runner.executorMap": {
"cpp": "cd $dir && g++ -std=c++14 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
},
Run Code Online (Sandbox Code Playgroud)
添加"-std=c++11",
到文件"args"
中的值task.json
。这应该可以解决您的 c++11 问题。所以最后你的task.json看起来像
{
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "g++",
"args": [
"-g",
"-std=c++11",
"-std=c++14",
"main.cpp",
"-o",
"test"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1921 次 |
最近记录: |