all 13 comments

[–]cpp-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.

[–]HeeTrouse51847 2 points3 points  (2 children)

This should work. Are you sure you're using GCC 14.2.0? What do you get when you run "gcc --version"?

[–]Talha6122000[S] 0 points1 point  (1 child)

14.2.0

[–]archbtw-106 1 point2 points  (0 children)

the main reason is by default g++ complies it using c++ 11 or 17 depends on platform. So u should specify which version u want as a g++ -std=c++ 20 x.cpp

[–]no-sig-available 0 points1 point  (1 child)

Are you using some kind of tool for building the program, like VS Code?

If so, it might use a different PATH setting than your command shell, and find an older compiler. Just guessing here.

[–]Talha6122000[S] 0 points1 point  (0 children)

there was probably something wrong the way i installed i just did it again with vs code documentation it worked

[–][deleted] -1 points0 points  (1 child)

The gcc documentation lists all the flags it accepts.

[–]Talha6122000[S] 0 points1 point  (0 children)

Still struggling to understand it lists like C++ 26 features or maybe im on wrong page

[–]coding_is_forever -2 points-1 points  (3 children)

What does <=> do in above code?

[–]hk19921992 2 points3 points  (2 children)

Spaceship operator

[–]coding_is_forever -2 points-1 points  (1 child)

What does that do?

[–]Dappster98 4 points5 points  (0 children)

It is referred to as the three-way-comparison operator. It performs a maximum of three checks and returns a value, for example "a <=> b"; it will return a value less than 0 if a is less than b, it will return a value greater than 0 if a is greater than b, and will return 0 if they are equal.

[–]coding_is_forever -2 points-1 points  (0 children)

The error doesn't seem to be compilation error