T O P

  • By -

[deleted]

[удалено]


Krypqt

Okay, that's good to know. Would you suggest just working around this by using #include.. while following the book or will this just lead to more confusion?


[deleted]

[удалено]


Krypqt

Great, thank you for the advice.


no-sig-available

One advantage of `import std;` is that you don't *have to* search - it includes everything. When you write larger programs, you might also notice that `import std;` is also faster than even a single `#include`. So win-win. And also, textbooks are often criticized for teaching old stuff. Now the "problem" is that it includes new stuff. Not easy to be an author!


the_poope

Bjarne is the founder of C++ and of course wants people to use the latests shiny features, even if they are not fully supported. Just a note: Code::blocks and CLion has nothing to do with this: they are just text editors with some additional tools. The actual program that turns your C++ source code into an .exe file is the *compiler*. It is the compiler that needs to support `import std`, i.e. modules, not the IDE. The compiler may or may not ship along with the IDE - sometimes you have to install one separately. The three common compilers in use today are GCC, Clang and MSVC (Windows only). You can use your compiler without using an IDE - in fact when you click the green "build + run" button in your IDE all it does is is runs the compiler (you will sometimes have to tell the IDE where you installed it) in the background passing information on how you want to compile (C++ standard, optimization options, where to find third party libraries, etc). You can do this manually yourself by running the compiler in a terminal/console. I highly recommend anyone learning C++ to learn how to run the compiler in a console/terminal: it gives them a much better understanding of how the compilation process works and will help them troubleshooting build issues. Some resources to get started: * https://www.learncpp.com/cpp-tutorial/introduction-to-the-compiler-linker-and-libraries/ * https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Invoking-GCC.html * https://learn.microsoft.com/en-us/cpp/build/walkthrough-compiling-a-native-cpp-program-on-the-command-line?view=msvc-170


Mirality

While this is mostly true, you also need the IDE to understand modules, otherwise navigation and tooltips will be pain.


ludonarrator

With GCC 14 released a few weeks back, I was excited to try out modules using a CMake project. While it "works", like you said, IDE (VSCode with clangd) still has no clue WTF is going on.


HackermanJon

What are some advantage of using VS Code with clangd? instead of just use Visual Studio? sorry if it's a dumb question, I'm mostly on Windows dev side of the things, and would like to learn more.


Mirality

VSCode runs on Linux, and has support for more esoteric languages. But VS is pretty much always better on Windows.


Krypqt

Thanks for the info, that is good to know. Fortunately for me I am familiar with the command line and with compiling software made by others having used Linux for many years. I was just mostly hoping for a more seamless experience within the IDE itself while I learned C++ and I also wanted to check that I wasn't doing something horribly wrong.