windows 代码::块错误“rad2deg未命名类型”错误“rad2deg未在此范围中声明”C++23

tktrz96b  于 2023-01-31  发布在  Windows
关注(0)|答案(1)|浏览(123)

由于在我的Linux机器上进行了测试,我知道这段代码写得很正确。无论我做了什么,错误仍然存在。我是Windows 10和Code::Blocks的新手,任何关于正确设置Code::Blocks或手头问题的帮助都将非常感谢。
我不知道我能做什么,因为代码是完全相同的。我不熟悉代码::块,我想我一定是配置失败的东西。任何帮助将是可怕的,谢谢。
Linux操作系统:

//g++ main.cpp -Os -std=c++23 -Wall -Wextra; ./a.out
#include <iostream>
#include <cmath>

int32_t main() {
    auto rad2deg = [](double rad) {return rad * 180.0 / std::acos(-1.0);};
    std::cout << rad2deg(6.2) << '\n';
}

窗口:

#include <iostream>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <ostream>
#include <cmath> 

int32_t main() {
    auto rad2deg = [](double rad) {return rad * 180.0 / std::acos(-1.0);};
    std::cout << rad2deg(6.2) << '\n';
}

预期输出:

355.234

实际输出:

error: 'rad2deg' does not name a type
error: 'rad2deg' was not declared in this scope
xdnvmnnf

xdnvmnnf1#

我通过在Settings -〉Compiler下更改编译器设置并将Compiler Flag更改为c17而不是c98(LOL)来让它工作

相关问题