感觉好久没有更新了,随便水一篇吧。

今天想升级一下MinGW GCC,发现MinGW也好久没更新了,经过一番搜索发现MinGW-w64符合我的要求,安装过程也很简单。

1. 从这里下载在线安装器

2. 选择自己需要的配置

安装MinGW-w64

3. 选择安装路径

安装MinGW-w64

4. 完成安装

安装MinGW-w64

5. 设置环境变量

安装MinGW-w64

6. 在cmd或PowerShell中输入gcc -v, 出现正确的版本号表示安装成功

7. 写一段代码测试一下

#include <iostream>
#include <any>
#include <algorithm>
#include <variant>
using namespace std;
 
template<typename... Args>
int sum(Args&&... args) {
    return (0 + ... + args);
}
int main() {
    auto [a, b] = pair(1, 2.0);
    cout << sum(a, b, 3) << endl;
    auto x = any(3.14159);
    cout << any_cast<double>(x) << endl;
    variant<int, double> v;
    v = 123;
    cout << get<int>(v) << endl;
    v = 1.23;
    cout << get<double>(v) << endl;
    return 0;
}
g++ a.cpp -std=c++17
./a.exe

8. 大功告成

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注