I know for a fact this code is written correctly due to testing this on my Linux machine. No matter what I have done the error persists. I am new to Windows 10 and Code::Blocks, any help regarding setting up Code::Blocks properly or the issue at hand would be greatly appreciated.
I have no idea what I can do since the code is exactly the same. I am unfamiliar with Code::Blocks and I assume I must have failed to configure something. Any help would be awesome, thank you.
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';
}
Windows:
#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';
}
EXPECTED OUTPUT:
355.234
ACTUAL OUTPUT:
error: 'rad2deg' does not name a type
error: 'rad2deg' was not declared in this scope
I got it to work by changing the compiler settings under Settings -> Compiler and changing the Compiler Flag to c++17 instead of c++98 (LOL)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.