Aaaand done. I've watched every single episode of this series, almost 15 hours in total. C++ has never been clearer to me, you're so good at explaining! I have an exam in C++ in about a month and I'm sure I'll do just fine. Thank you, Cherno!
@pilotandy_com5 жыл бұрын
How did it go?
@chappy18355 жыл бұрын
@@pilotandy_com He failed.
@louisdaza19234 жыл бұрын
Chappy made my day dude lmao
@jerfersonmatos284 жыл бұрын
Me too, I've learned a lot
@vishalbhat86023 жыл бұрын
@@chappy1835 LOL
@domidivo4 жыл бұрын
I wish I could precompile all your c++ tutorials and load them directly to my memory lol.
@hst24093 жыл бұрын
*to my disk would be better :)
@TheArrowedKnee3 жыл бұрын
Nice
@walkmoon34792 жыл бұрын
no hard loading, just create a pointer is easy
@projektingenieur84914 ай бұрын
@domidivo Jdownloader can do this for you
@cicciobombo74966 жыл бұрын
Oh yes more c++ juice
@alexandergonzalez59756 жыл бұрын
Ciccio&Bombo Lol
@elvinzhang91206 жыл бұрын
yammy
@diverseprogrammer185 жыл бұрын
That sounds weird but yeah.
@Destroyer199419955 жыл бұрын
mmmmmm Nice bath in c++ enslaved moisture
@mbrown12533 жыл бұрын
For those using g++, be sure to use the exact same g++ compile options for your precompiled headers as when you compile your project. Also if you're unsure whether your header or the PCH is being used when you compile your project, try adding the -H option when compiling your project. The -H compiler flag will print out which files are compiled, including each header. If the PCH is set up properly you should see a line like "! pch.h.gch" The exclamation point (!) indicates it was successful. If instead you see an X, that indicates there was a problem with the PCH. If you don't see this line and instead are presented with a wall of text printing out each header that was included in the compile, then your header was used instead of the PCH.
I've been following Your channel for like a year now, and I have to say, every video that you make is extremely high quality, both visually and content wise.
@olliveraira61223 жыл бұрын
18:42 precompiled headers with GCC (no fancy stuff lol, just a regular compilation)
@Buiscit17386 жыл бұрын
g++ precompiled headers? Awesome videos. Joining the Patreon crew. Your videos are better than most c++ books I've read!
@passionfruit76172 жыл бұрын
what's g++?
@jukit39062 жыл бұрын
@@passionfruit7617 one of the main C++ compiler for non-Windows platform (with clang, although clang is more macOS while gcc and g++ more linux afaik)
@jukit39062 жыл бұрын
@@passionfruit7617 It's stands for GNU C++ Compiler (GNU stands for GNU is Not Unix, and is an operating system that was **kinda** discontinued but its compiler collection (GCC) has become widespread)
@michaelswahla49272 жыл бұрын
g++ -> c++ compiler gcc -> c compiler
@rishabh542811 ай бұрын
well g++ should be the same as gcc
@LowLevelLemmy Жыл бұрын
cherno, more like cheryes
@Max-wk7cg6 жыл бұрын
I've been using them for a while and my first impression was that they are awesome, I just wasn't aware of their potential problems and I'm glad you mentioned them here. I'd like to add that if you are having trouble figuring out header file dependencies when using a precompiled header you should use the /showIncludes compile switch if you're using the msvc compiler. It will print out every header file dependency as they include each other. It's very very useful!
@drwisdom15 жыл бұрын
Ding! Ding! Ding! This is Mr. TheCherno's best video. Back in the 1980s/early 90s when computers were really slow, my Symantec C++ compiler had precompiled headers which really improved compilation speeds. Now computers are super fast so compiles don't take long, except in one instance - when compiling source that uses windows.h and is stored on a network drive rather than a local drive where it gets cached. I could have been using precompiled headers for the last 30 years and will now investigate if it will provide significant time savings. Of course I have some criticisms but they are small compared to the positives of this video. It took Mr. TheCherno 12 full minutes to say "you don't want to sit around waiting for constant code to compile, use precompiled headers to reduce wait times." I don't care about flipping screens and filling in blanks in Visual Studio, show me the command line so I don't have to research it.
@muhammadtalhabaig49085 жыл бұрын
And thats it! I have completed this C++ series! And I have to say compared to what I learned in almost an year at my university, I learned more in a week following this series 😃. Thank you cherno for this amazing series and i am looking forward to watch game engine series and others as well! You are my fav teacher from now on 😁. keep up the great work, you are the best!
@Rose_Harmonic3 жыл бұрын
I took a semester of c++ six years ago. I was surprised how quickly he eclipsed everything I learned.
@cargle75146 жыл бұрын
Started using Windows Console Application template in VS and was wondering why the pch.h file was auto-created. Thanks for the information! This helped a lot.
@jeroenkoffeman94024 жыл бұрын
here's an easy way in vs to force include your pch.h file in every source file: Configuration Properties -> C/C++ -> Advanced Type "cph.h" in the "Force Include File" field; this will make the visual studio compiler insert the header file at the beginning of each file without having to include it manually.
@TheDezmen33 жыл бұрын
Tried, doesnt really work when u edit cpp file, it wont find stuff without including header manually
@jeroenkoffeman94023 жыл бұрын
@@TheDezmen3 hmm for me it works, did you set it for "all configurations" ? Just checking
@zeevsolomonik61623 жыл бұрын
Modules are one of prominent features of standard C++20. They overcome the restrictions of header files and of the preprocessor usage. I would recommend to pay closer attention to this feature since it will eventually boost C++ packages management.
6 жыл бұрын
Correct me if I am wrong but the compiler does not compile the whole std::vector just because you included it. The only template code thats going to be compiled are those that you use (instantiate). So for example if I instantiate a vector and use the push_back method, the only code thats going to be generated are these 2 functions.
@edtExodus6 жыл бұрын
The issue isn't necessarily the code generation, but figuring out what code needs to be generated. The pre-processor still needs to parse the entire code unit to figure out what actually needs to be compiled.
@sl66ggehrubt6 жыл бұрын
Wouldn't it be nice if every function was just available, and only included in the compile if called... How can I #include everything? I've got a fast computer.
@shadowmil6 жыл бұрын
This is correct. Many compilers don't even parse the template (aside from finding the end) until it does get instantiate. Which can cause the awkward situation that certain syntax errors won't showup unless you instantiate.
@annabelletrinh9363 жыл бұрын
For XCode user: → Your pch file should be in the format -Prefix.pch - Go to Build Setting → Turn on → Add the path to your pch file in You don't need to include it in your *.cpp file, it's automatically included.
@serenitynow19785 жыл бұрын
Dude, your vids kick ass++ Thorough, informative, concise This time we get all three Thank you for your time and efforts
@Debaser36 Жыл бұрын
When I use precompiled headers, I always still write the includes in the cpp files and just comment them out :)
@mohabmohamed58466 жыл бұрын
a cmake video please D:
@GfastGao6 жыл бұрын
Or say: Do this in a VS-Free way.
@VictorOrdu5 жыл бұрын
@@GfastGao VS currently integrates cmake
@lummwastaken4 ай бұрын
You can add a PCH to a target in CMake using "target_precompile_headers" like so: target_precompile_headers( PUBLIC | PRIVATE | INTERFACE [["header_name_1.h"]] [["header_name_2.h"]] [["header_name_3.h"]] ...etc. ) Only works if you pass in a compiled library or executable target. You can also reuse precompiled headers in later targets using the following: target_precompile_headers( REUSE_FROM )
@lucifer9033 Жыл бұрын
this is awesome. thank you brother.
@AmeshaSpentaArmaiti6 жыл бұрын
It hadn't occured to me that general C++ tutorials would still be coming alongside game engine tutorials. And I'm still learning new things. Why does c++ have so many "hidden" features? I've never heard of precompiled headers.
@Arganoid5 жыл бұрын
It's technically not a feature of C++. It's a feature of certain compilers such MSVC.
@Llourn5 жыл бұрын
What an awesome series of videos! I reviewed the whole series from start to finish over the last 3 days and looking forward to starting the OpenGL series next! Thanks a million for the fantastic material.
@Mozartenhimer4 жыл бұрын
Ahhhhhhhh Adding this to my project felt good. Every tutorial ever always says not to use PCH, probably just to avoid the complications, but man alive, it was nice pch to my personal projects. That plus enabling multiprocessing builds in VS took my clean build time to 2.2 seconds. Was 5.7 seconds before this. That means a lot to me. I just love to compile all the time.
@user-sl6gn1ss8p3 жыл бұрын
hey, do you by any chance know how to enable multiprocessing from premake? I looked around but couldn't figure it out : / Nevermind, just found it, lol. In case anyone cares, it's very straightforward, just add: flags { "MultiProcessorCompile"}
@TheMrTape6 жыл бұрын
Absolutely perfect. Thanks for doing this.
@pu3zle5 жыл бұрын
Just finished your C++ Course. I hope you'll keep posting more videos about C++ because I've learnt so much thanks to you. Don't abandon this series. :D
@hichamwarryor35473 жыл бұрын
Thanks so much
@oualice94105 жыл бұрын
Thank you, Cherno, for making those wonderful videos. You are benefiting people and contributing to a better world!
@agfd56596 жыл бұрын
Maybe you could make a video about unity builds and the differences (positives, negatives) compared to the more common way of building programs.
@shavais334 жыл бұрын
Is there a way to use more than one precompiled header file in a MSVC++ project? It would be nice to separate the external headers that (almost) never change from internal headers that rarely change, but which do change from time to time. Then if/when I do have to change some rarely changed header, at least I wouldn't have to wait for all the external headers to recompile. Aside from combining translation units into one, are there any ways to further mitigate per translation unit compilation delays? I tend to end up with a ton of .h and .cpp files, and far more often than I'd expect, all or most of them end up getting recompiled when I run the build. In watching the compile, it definitely seems like there is a non-zero compile time cost associated with just having a translation unit at all, even if it has hardly anything in it. So I have this tendency to create "bundle" .h and .cpp files, that just #include a bunch of constituent .h and .cpp files, and then exclude those constituents from the build, so that way there are a lot fewer translation units to build. It definitely speeds up the build, but. I feel like there has to be a better way. Is there a good, succinct resource for reviewing the hows and wherefores of headerless C++ coding? Is there a good, succinct resource for reviewing the nuts and bolts of building Zero Overhead Abstractions? Recently I've been re-reading Bob Martin's book, Clean Code. One of the Big Ideas in it is to keep classes and functions really super small by dividing big ones up into smaller ones. I've tried that before, and I've kind of discarded the idea, because it seems like it's a lot more trouble than it's worth; but now that I have a lot more coding experience in general, I'm tempted to maybe re-approach it. But performance and efficiency are my foremost concerns, and build time is another big concern, and time spent coding tons of little classes and functions is another matter that kind of still gives me pause about it all. I think I need to better understand how I can - avoid having to maintain separate declarations/headers for every little constituent class and class member, - place their scopes into physical hierarchies (since named functions can't be nested in C++) without proliferating too many namespaces / long ns chains, - organize and control their individual scopes, both cognitively and in terms of their impact on the build, and - build zero-overhead abstractions. There's a fair bit that I already know about all that, but. If there isn't more to know than I know, then I guess I'm still kind of feeling like trying to really make super small classes and class members in the way Mr Martin talks about isn't really worth it in C++.
@tomaskot92785 жыл бұрын
I was scared of precompiled headers and I've always disabled them in the project settings. Now I see how simple they are in fact, so I'm definitely going to give them a try. Thank you very much!
6 жыл бұрын
I was searching for a way to speed up building my codes, and PCH will probably have a huge impact. Thanks again for the tips and tricks.
@HamzaHajeir5 жыл бұрын
Perfect series, Thank you Cherno :) Can you make a video about async calls. I have an embedded systems background and because MCU's are single-threaded, async calls are used, thus presence of async libraries, I am interested in developing libraries i use by using async calls.
@ekhidnis5 жыл бұрын
Phew, I've finished the series! Thank you a lot for sharing these and I wish you having a happy life there!
@kiocode5 ай бұрын
i like the rabbit
@rdappel Жыл бұрын
I've been using them wrong for years lol. At my last job our tech lead had us throw everything in there. Having never really used them before, I didn't question it. Makes total sense now! Thanks for the video!
@AntonioNoack4 жыл бұрын
Hearing from them the first time, and I think they are great. It's a little sad, it's not done automatically by VS etc...
@marotonin76203 жыл бұрын
How can I add precompiled header file into a file inside subdirectory? if I use "../pch.h" it won't recognize it it needs to be "pch.h"
@razvanfilea80766 жыл бұрын
I think he said "Right?" about 40 times lol
@Puffadderr6 жыл бұрын
Right
@rcookie51286 жыл бұрын
Right!
@Saboteur7096 жыл бұрын
I don't know if that's right. :)
@9100eric4 жыл бұрын
lmao that's very close, he actually said it 59 times (at least that's in the transcript)
@JacobWrecker4 жыл бұрын
Right
@UlyssesAza4 жыл бұрын
This is genuinely a great video thanks a lot.
@chuthetai30116 жыл бұрын
Thanks a lot 😁
@kvitnat4 жыл бұрын
never even heard about that i m a last year CS student from Ukraine and i just got my first job as c++ programmer and i'm pretty sure i wouldn't have passed all the tests and the interview if it wasn't for your c++ videos thanks a lot)
@lnx6483 жыл бұрын
Potentially stupid question: if I add a lot of files into the the precompiled header, and then I include the pre compiled header, am I not including a lot of potentially useless code into every file of my project and yes speeding up the compile time but also increasing the final executable file size? Will turning off precompiled headers for say a release build make the compiler ignore included files that are not being used, therefore I can expect a larger executable file during development, but a smaller executable in release? Or the difference in sizes is so minimal I can avoid caring at all, considering large projects too of course.
@foomoo10882 жыл бұрын
I don’t use them for the reasons mentioned . I like keeping track of my dependencies, don’t use STL, and use a “game module” approach. True, my project is not super big yet but so far the modular design and limiting dependencies gives quick compile times.
@foomoo10882 жыл бұрын
Unreal engine also moved to the “include what you use” philosophy a while ago (similar approach in my personal engine)
@thoaxm6687 Жыл бұрын
@@foomoo1088 CMake's target_precompile_headers() force includes the PCH into the translation units so source files can stay the "include what you use" way. (Still means you shouldn't bloat the PCH with absolutely everything, of course).
@drop0ne_f202 жыл бұрын
0:04 Hello The Cherno! Welcome back to my PC. :) LOL I made a funny! FYI I am aware I am not funny but that will never stop me :)
@laszlopaal91045 жыл бұрын
Can you please add video on how to write cache friendly code in C++? Bad and good design examples would be great.
@adamhendry945 Жыл бұрын
Can you please also do a video on the pIMPL idiom/method and on alignment and padding?
@thatrandompalmtreeyousawon20683 жыл бұрын
Man after following this series for a while I'm confident that I can get to building my first game in C++ soon
@marcpanther79246 жыл бұрын
I love the People's Elbow gesture in the beginning
@MeeroSom3 жыл бұрын
This is 2021, August, I have never heard before about precompiled headers... Thank you for introducing them though, this is as if I would already be a kind of a member of a kind of a learning company, and you as a kind of senior co-worker explain the tricks of the old foxes. As if.
@georgea28352 жыл бұрын
Stupid arm thing at the beginning of the videos is everything
@郑祺瑞5 жыл бұрын
Thanks, cherno! We are finsihed this courses!
@electroturi5 жыл бұрын
Can you have several pre-compiled headers in one project? Maybe like that you can pre-compile external dependencies in one PCH and then have your own code (or part of it) in a different PCH. This could be useful, no?
@benhetland5764 жыл бұрын
@electroturi Yes, you can have several pch in the same project, but perhaps not in the way you are thinking. AFAIK in Visual Studio you can only make use of one pch in each cpp file. There is a caveat too, and that is that the #include "pch.h" must be the first effective codeline in that cpp file. Everything before that line is actually completely ignored by the compiler! If the lines are just comments, that's no problem of course, but if you accidentally put something else important there, you will eventually be bitten ... My guess is that the implementation is simply such that the compiler just loads its entire internal state from the pch, then continues compiling from the line after the include pch.h. Whether it is similar in g++ and clang, I don't know, but that would be the reason you cannot load several pch in the same cpp with MSVC at least.
@澳洲程序员大卫4 жыл бұрын
Well explained, thanks!
@feraudyh5 жыл бұрын
Best explanation I have ever seen.
@mrinmoybanik55982 жыл бұрын
Can you make a video on how to precompile .hpp headers from command prompt?
@baconsledge5 жыл бұрын
Excellent video series!
@mohammedbadaway74904 жыл бұрын
Thank you
@mihirluthra77624 жыл бұрын
Glad I came across your channel :)
@ajinkyax3 жыл бұрын
is there a way to do same with a CMake project ? Those properties you showed wont open in Visual Studio 2019 for a CMake project.
@samziggler78374 жыл бұрын
New to me, it's a go for it to me
@jeroenkoffeman94024 жыл бұрын
Am I missing something? What about the header files? If I can only include precompiled headers in the source file, then how do I declare any of those types in a header file? i.e: If I include and in pch.h, how can I declare a vector in any of my header files? Thanks in advance!
@jeroenkoffeman94024 жыл бұрын
Or I guess the #pragma once ensures that it doesn't need to compile these headers from my header file. So i can just still include them in my header file one by one. During compiling the source file will include the pch.h first, so it will never include them from my custom header file. Am I right?
@Tel297675 жыл бұрын
Love your series. Could you do a video on file input/output at some point as well please?
@simonmarchand18186 жыл бұрын
Hi Cherno, do you work on unreal engine and will you do some video about it ? Thx for this C++ series as well as the game engine one, it is very useful in my studies.
@kplays_60006 жыл бұрын
No, he doesn't
@esben1816 жыл бұрын
I believe Udemy have some excellent courses on that topic if you are willing to spend a few bucks.
@kplays_60006 жыл бұрын
@@esben181 Don't bother with Udemy, just look around on KZbin and use the official tutorials, there's plenty of free content out there.
@shaunyitisme32936 жыл бұрын
@@esben181 Thx but I just like the quality of Cherno's video and wanted to know about future projects.
@jcdentonunatco6 жыл бұрын
The Unreal C++ course on Udemy by Ben Tristem is really good, and very cheap, I definitely recommend it.
@veeecos5 жыл бұрын
Could you please do a video on custom data structures next ?. I know you had mentioned them a while ago.
@DaveChurchill6 жыл бұрын
I was really hoping that you would somehow put this into the premake file, that would be awesome
@michaelpacheco74215 жыл бұрын
Waiting for more videos! CMake is a good choice.
@carlodiferrante95776 жыл бұрын
What about compiler cache? looks like a simpler and more ffective solution.
@HiAdrian5 жыл бұрын
Yes, I think a compiler cache is a much better solution!
@omar_alzeer2 жыл бұрын
You are a legend !!
@Arganoid5 жыл бұрын
They used to lead to project folders taking up huge amounts of disk space (in Visual Studio, at least) - eg a simple Hello World app could take up gigabytes. Is this still the case?
@dijkstra46782 жыл бұрын
very informative
@Xx_McJasper_xX3 жыл бұрын
First time I've heard of it. This is one of the problems with university education. You learn tons of theory but never hear about the practical tools/tips/tricks that professionals actually need.
@scottnivens99363 жыл бұрын
Why am I learning about PCH's only now?! I managed to reduce the time for a full compile by >75%! WOW! Thanks!
@abdulelahaljeffery62346 жыл бұрын
compiling .h file with clang++ gives a warning: clang-6.0: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated] .hpp compiles fine.
@lazyh0rse Жыл бұрын
I keep getting "unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source?" to all my cpp files, I did exactly as the video did, cleaned project. Still not working. Turning it off make compilation successful. Any help?
@huiguo14894 жыл бұрын
I wonder how to use this trick in a CMake project. Is there an example?
@xrafter4 жыл бұрын
I have make that work will but cmake i don't know
@gowtham2364 жыл бұрын
Didn't know about this feature.
@victorz77482 жыл бұрын
This is definitely a looooooooooooooooong hello world 13:29
@anthonyhalim9266 жыл бұрын
Would love to see a video about typedef, typename, and using keywords! Love the videos
@CreativeOven6 жыл бұрын
i love precompiled headers i hate waiting when compiling
@xingsir5 жыл бұрын
Thank you. I really like this kind of video. Please more :)
6 жыл бұрын
Make a video about set and unordered_set in C++. I need them for a project at my university. Especially how to implement them for a custom class/structure. Or, maybe give me a good source from where to learn this, because I've had hard times trying to implement unordered_set for my custom structure.
@a_cats7 ай бұрын
Clangd complains that I'm not using the header directly, should I just disable that warning or is there a standard way to deal with this? The fact that it's warning at all makes me feel like there's a convention for pchs that I'm not aware of
@shikharchaudhary69845 жыл бұрын
amazing video
@Automatyk6 жыл бұрын
Hi, what is with my project... I setup all like you and VS gives me a linking error: "LNK1104 cannot open file 'Debug\pch.obj'". Any solves?
@h.hristov5 жыл бұрын
Cover move semantics next yes
@AustinJerry5 жыл бұрын
Hey, Cherno can you make a video on maps?
@brod5156 жыл бұрын
Wow! I knew there was search a thing as pre-compiled headers just didn't really know what they did.
@mul75226 жыл бұрын
Is it only the template stuff that is included that needs to be compiled? If you don't include template headers and only have regular ones then it doesn't need to compile the header?
@Stygianstevedore5 жыл бұрын
How do precompiled headers interact with something like ccache, which tracks compiled objects and keeps you from having to recompile unchanged files? Do they do basically the same thing?
@jeroenkoffeman94024 жыл бұрын
Will the compiler automatically only include the code that the sourcefile actually uses? Otherwise, wouldn't precompiled headers make your program larger? Because it adds all the includes to every source file, instead of only the necessary ones for that specific source file. Thanks in advance
@billbasener87842 жыл бұрын
Another great video. I can precompile headers and my main.cpp compiles fast now from the command line, but when I compile it in VS code, which seems to just use my command line call, it takes a very long time. Anyone know why?
@yellowlegend2455 жыл бұрын
another question, 1. cant we have different pch.h file for different projects 2. i see it makes difference on development time, does it have any performance on final executables also? or is that same No need to say, that your explanation is awesome, better than many classroom teachers.
@norb3695 Жыл бұрын
19:10 how did that thing generate 117 megabytes in such a small time what???
@hiraasif42274 жыл бұрын
When are you going to make video on "File Handling in C++" , I can't find any fruitful video on that! Please make a video on that!! Moreover , I just love the way you explain things and you are really my teacher now a days. I have my final tomorrow of OOP, and will pass it just because of you! Thank You Sooooo Much! Have a Nice Day!
@kalelalves2 жыл бұрын
Before anything... Amazing videos. I love the way you explain stuff man. You're really good at that. 11:50 i know this is pretty old, and I agree that PCHs area must for those kinds of libs, but dude, you keep saying you don't want to recompile it everytime, regarding the STL... And that not entirely false, cause you end up recompiling symbol references you use and parsing the h files into your translation unities,, but the library is already compiled in the c++ runtime, or other libs/DLLs you use. So it's also not all true that you end up recompiling all that stuff. If you would have to, then you would see the amount of time that that takes, it's absurdly larger and longer than just parsing headers... That's one of the main header/source separation reasons. Unless off course you use some bad lib that needless defines a lot of stuff in headers. I'm certain that you know all that, but saying that might be confusing for the people that does not have good knowledge about c++ or linking in general and possibly give them a bad ideia of what that whole system actually does. I just think that it's something that should be mentioned, although, I'm not as good at teaching as you are, so I might be wrong as well haha, and this is something people shouldn't have to know at first, like how you get to physics formulas when you first learns physics cause you have no idea of integral calculus, limits, and so actually is. I still think it should though. 😂
@TheDezmen33 жыл бұрын
But what about .h files that have vectors/maps etc elements if pch.h is included in .cpp file
@esben1816 жыл бұрын
A video in the middle of the week! What an amazing surprise :D Thank you
@jeffvenancius Жыл бұрын
What if I create Macros to include the headers I need, but only on release? Is that possible?