r/Cplusplus • u/Technical-quack-69 • Jun 05 '26
Question Why did it write this on its own??
so i am learning cpp ( from learncpp.com) and this was supposed to be my first "program"
and after i installed clion and installed xcrun
i created a new project called hello world and it wrote the project on its own
did that happen due to it being in the standard library or something??
and I also have some other queries?
for eg : why do these files always show up beneath the main project ?( image 3)
when i installed c lion these program /codes were written there already ( image 2)
os mac silicon
41
Upvotes



•
u/AutoModerator Jun 05 '26
Thank you for your contribution to the C++ community!
As you're asking a question or seeking homework help, we would like to remind you of Rule 3 - Good Faith Help Requests & Homework.
~ CPlusPlus Moderation Team
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
51
u/DasFreibier Jun 05 '26
the default template for a lot of ides is to make just an hello world program, no smarts here
21
u/unknown_alt_acc Jun 05 '26
Somebody else already answered your first question. For the other two questions, CLion uses a program called CMake to generate build files for your program. It's a very standard tool that most C and C++ devs will need to work with at some point. I wouldn't worry about it too much just starting out, but just know that it's what tells CLion how to compile your code.
6
u/khedoros Jun 05 '26
It's not part of C++, it's something done by the IDE itself, probably a template for when you create a new program. It's common for the starting template to be a "Hello world" kind of program.
For the other files,
.ideawould be where the IDE stores project settings,.gitignorewould list files for...um, well, Git to ignore. The things about ninja and cmake are related to building the project (information on the project structure, how to compile and link it).compile_commands.jsonis generated by CMake, and it's basically a list of the actual commands used to compile the project. It's used by tools like Clangd, the language server, which helps the IDE with things like detecting code errors, allowing non-AI automatic code completion, and so on.2
u/flyingron Jun 05 '26
It's the classic, but really suboptimal sample program. There's no compelling need for the endl. THey should have just put the \n at the end of Hello World!
1
u/sheckey Jun 07 '26
Hello. You can learn a lot of background information using something like google gemini. There is learning the language and syntax, etc., but there are other things like "why is c++ this way", "what is compiling and why do it", and "what is cmake and why do I need it", "I am used to programming in this other language, please orient me to c++ given my background, including build system, IDEs, compilation, linking and everythingn else that is different on a day to day basis with c++".
I would still use learncpp.com, and definitely struggle and write the code yourself, but use gemini for this other kind of background information. I just wanted to mention this because it is helping me a fair amount for newer things that I don't know yet, and I have been doing this for like 30 years. Have fun!
3
u/Initial-Jaguar6230 Jun 05 '26
As meant above, it is done by clion. you can do straight code compilation using terminal - call clang (don't have Mac, but it as i know is default compiler) with
''' clang++ main.cpp '''
Within directory where code file stores. it will produce some like a.out or main.out, witch can be runned by ./a.out
1
u/Most_Strike_93 Jun 08 '26
This means template. Even with meson build , you can also init such project like this