#Spaceships, Compilers, and Errors

1 messages · Page 1 of 1 (latest)

pseudo meteor
#

I'm in visual studio trying to compile c++ code in c++20 or above, however doing a simple compilation command with gcc 12.2.0 doesn't recogize a c++20 operator. What've I done wrong?

obsidian karmaBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

#

@pseudo meteor

Screenshots!

Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!

indigo smelt
#

that's not what the spaceship operator is for

pseudo meteor
#

I'm only trying to test that I have c++20 working, not anything in particular. I'll send the code though:

#include <iostream>

int main() {
    auto result = (10 <=> 20) > 0; //test if C++ 20 is supported
    std::cout << "result: " << result << std::endl;
return 0; }
#

This works in other places^

indigo smelt
#

wait nvm spaceship is a real operator with uses other than overloading

#

oh

#

you need to pass -std=c++20 to the compiler

#

compilers still default to C++14

pseudo meteor
#

ah okay one sec

#

Not sure

#

wait they're out of order

#

g++ -std=c++20 -o executable_name cpp_name.cpp worked

pseudo meteor
#

!close