Блог пользователя IG0R

Автор IG0R, история, 3 месяца назад, По-английски

I've recently decided to try out CLion, and it works just fine but when today the announcement was made that C++23 is added to Codeforces i wanted to try out C++23 in CLion. When creating a new project I selected C++23, but actually when I try to use some of the new features like $$$print$$$ it doesn't work ($$$print$$$ was not declared in this scope, and when I try to do $$$#include <print>$$$ it says there is no such file or directory). It seems like it actually isn't C++23, though the command for compiling the code is using -std=gnu++23. Do you know how to fix it?

  • Проголосовать: нравится
  • -7
  • Проголосовать: не нравится

»
3 месяца назад, # |
Rev. 7   Проголосовать: нравится +1 Проголосовать: не нравится

Had the same problem. Here is what i did:

1.Update CMake and GCC (that was probably the main reason why it didn't work, i had GCC 6.0 and CMake 2.7, now i have GCC 14.1 and CMake 3.0)

After you did this CLion will probably stop saying that there is no print, but you may start getting strange error like this when trying to compile program with std::print

To fix this do following:

2.Go to your CLion project and find CMakeLists.txt

3.Find there add_executable(/your_project_name/ main.cpp) line and put target_link_libraries(/your_project_name/ PRIVATE stdc++exp) after it.

4.Click this small button, it will appear just after you put a new line

5.Run project

(The project should be created selecting C++23 just as you did)

  • »
    »
    3 месяца назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    Thanks for the help! It actually was a bit more complicated for me because I already had gcc 14.1 and CMake 3.30, but the thing was CLion was not using gcc 14.1 but gcc 13.1 which was auto detected by CLion, but after changing that and doing what you told me it works fine.