簡體   English   中英

g++ -std=c++17 給出行和行錯誤

[英]g++ -std=c++17 gives lines and lines of errors

我正在嘗試使用 MinGW g++(i686-win32-dwarf-rev0,由 MinGW-W64 項目構建)8.1.0 編譯此代碼

#include <bits/stdc++.h>
using namespace std;
int main()
{
   map<int, int> mmap;
    mmap[0]=10;
    mmap[1]=20;
    mmap[2]=30;
    mmap[3]=40;
    mmap[4]=50;
    for(auto [x,y]:mmap){
        cout<<x<<"->"<<y<<endl;
    }
    return 0;
}

使用 c++11 標志編譯給出了這個

E:\Code>g++ temp.cpp -std=c++11
temp.cpp: In function 'int main()':
temp.cpp:89:14: warning: structured bindings only available with -std=c++17 or -std=gnu++17
     for(auto [x,y]:mmap){

並使用 c++17 標志進行編譯會給出一行一行的錯誤。

g++ temp.cpp -std=c++17

好的,所以我想通了,這是第一行

#include <bits/stdc++.h>

包括 iostream 和 map 而不是上述行會導致編譯干凈。

#include<iostream>
#include<map>

現在我還有一個理由為什么我不應該#include <bits/stdc++.h>?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM