本文介紹了如何為 C++ 14/C ++17 設置 VS 代碼的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我試圖從工作區運行一個 .cpp 文件,但給了我這個關于不添加 c++11/higher 標志的錯誤,但我已將它們添加到 task.json
I tried to run a .cpp file from workspace but giving me this error about not adding c++11/higher flags but I have added them in task.json
錯誤
[Running] cd "c:UsersNuhashDesktop est" && g++ main.cpp -o main && "c:UsersNuhashDesktop est"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) {
Task.Json
{
"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"
]
}
]
}
錯誤信息:
[Running] cd "c:UsersNuhashDesktop est" && g++ main.cpp -o main && "c:UsersNuhashDesktop est"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) {
c_cpp_properties:
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"
}
推薦答案
我添加了代碼運行器并將其添加到 settings.json 似乎對我有用 :D
I added code runner and added this in settings.json Seems to work for me :D
"code-runner.executorMap": {
"cpp": "cd $dir && g++ -std=c++17 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
},
這篇關于如何為 C++ 14/C ++17 設置 VS 代碼的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!