Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does GCC support C++23 std::print?

Tags:

c++

std

gcc

c++23

fmt

On CppCon 2022 was announced, that new official HelloWorld in C++ is now:

#include <print>

int main() {
 std::print("Hello world\n");
 return 0;
}

Do you know, is std::print available in GCC ? Maybe it needs some flag or additional library to activate?

Link to description https://en.cppreference.com/w/cpp/io/print

like image 967
Vladlen Avatar asked Mar 30 '26 22:03

Vladlen


2 Answers

The status of C++ features is tracked via their feature test macros. cppreference.com helpfully lists those. They would be __cpp_lib_print and __cpp_lib_format for print and format, respectively.

You can then search for those macros in the C++ Standards Support in GCC and Implementation Status of libstdc++. Right now you will find no mention of __cpp_lib_print while __cpp_lib_format is listed but not implemented. So the answer is no.

You can check your own compiler with the feature testing facilities of C++. An online compiler like godbolt.org is a quick way to test most mainstream ones.


UPDATE:

std::print and std::format support had been added to GCC since version 14.

To check, just invoke

$ g++ --version

see the output and -in case- update the compiler.

like image 179
Homer512 Avatar answered Apr 02 '26 13:04

Homer512


No it does not support std::print.

Here is a list of the feature availability for C++23 in GCC and other compilers.

like image 28
Volkan Güven Avatar answered Apr 02 '26 13:04

Volkan Güven



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!