Название | : | BETTER Header Files and Preprocessor Debugging |
Продолжительность | : | 24.26 |
Дата публикации | : | |
Просмотров | : | 60 rb |
|
hey man, what font do you use? I really liked it! Comment from : @CaioVinicius-xc9cl |
|
Do you have an opinion of STB libraries? Comment from : @BboyKeny |
|
also, forward declaration in header files, so you don't include headers inside other headers, you avoid cycles and your compile times also get lesser Comment from : @imblackmagic1209 |
|
Hm thanks for an inspiration I've got some cool ideas Comment from : @wojciechsobiesiak |
|
the main problem is that headers exist in the first place Comment from : @luvincste |
|
cool Comment from : @mehmetedex |
|
Yikes, this guy needs to go back to uni take a class This was painful Comment from : @yourfan2673 |
|
I sir I want all basic videos link Comment from : @shankarbagwale3100 |
|
Do you know if its possible to output the preprocessed files for Unreal code ? I can't find the option Comment from : @alexandresendra |
|
Hi cherno! brWhat about a series on Vulkan like you did for OpenGL? Anyways love your contents!! Comment from : @cesarecorsi5968 |
|
2:30 There is good analogy for that Epigraph and content page in books It comes first to tell you what you can get from it Comment from : @severgun |
|
Dude, I love you and appreciate these videos so much Thank you for creating and sharing the series! Comment from : @bobbyv3 |
|
At work we use a lot of forward declarations reducing the amount includes It is a pain having a code style change in a header file that triggers a waterfall of compilations Comment from : @deeplazydev |
|
Team Deep sounds a bit suss tbh 😅 Comment from : @Marius-vw9hp |
|
6:20, 6:30 I heard all the same things Because of all the ambiguity, if I REALLY want something "inlined" and it's relatively small (2-5 lines) I implement it as a macro so there's no doubt what the compiler is doing with it Comment from : @CR3271 |
|
Thank you for your nice video and helpfull tipps One word about defining functions in the header file: it's not only a matter of code size IMHO i don't want not leak too many implementation details by my header files, especially if I'm writing library code Implementation details in my header files can create unnecessary dependencies between my modules and make the use and refactoring of my library code much harder Comment from : @martinfenner3222 |
|
He is a Handsome man 😊 Comment from : @muratoe8121 |
|
theme? Comment from : @azaktivalasienergiaendoter814 |
|
6:48 it used to be that "inline" keyword was about actually inlining functions, but nowadays the compilers decide what to inline according to various metrics The "inline" keyword affects this metric, but a very small amount The real effect of "inline" is related to ODR But you need LTO / LTCG enabled in order for functions to get inlined across translation units - in that regard defining functions in a header helps, but not the inline keyword itself And you should always mark functions with headers "inline" because otherwise you're looking at ODR violations and linker errors about "multiple definitions" Comment from : @VioletGiraffe |
|
What will be first - private section or public is topic for holy war Because in some cases I can open header file for see internal stuff (private) or in other cases it can be external interface (public) I my opinion if this sections have big bunch of fields and methods (like in this example) it just need separate on few classes If class will be simple it don't different what section will be first or second I will see all header file at on single screen Comment from : @romanvladimirov5247 |
|
does anyone know what vs theme is in this video? Comment from : @administrator775 |
|
Wait, isn't it better to pass variables by const reference if their values aren't going to be changed? Comment from : @michaplucinski142 |
|
Love this series, thanks much Comment from : @paxdriver |
|
Newer subscriber, so sorry if you've already talked about this in another video, but what about pimpl to keep your headers cleaner? I know, less chance of inlining, but curious about your thoughts And to your commenters talking about modules: my opinion is wait unless you are Microsoft only gcc and clang aren't there yet Comment from : @JohnJonesJMJAtlanta |
|
Better header file is the file that is not a header file Comment from : @lanchanoinguyen2914 |
|
Oh Lord if you ever saw my code, you'd probably leap through my monitor screen and strangle me Comment from : @MDFeingold |
|
i love it very good! Comment from : @Killputin777 |
|
Little question: I'm wanting to build my own GUI-app with a 3D rendering scene and a menu on the side I've seen the ImGUI video from Cherno Is it still one of the best options, for a beginner? Comment from : @Windeycastle |
|
You need to make a video about const and mutable stuff that you did at the end Comment from : @ThePowerRanger |
|
Really weird place to put the sponsor-segment, but I learned some usefull things today! Comment from : @Windeycastle |
|
One thing about private vs public members firstbrbrUnfortunately the order of member variables affects the class size in memory due to data alignment So sometimes it can get a tiny bit more performance in exchange for separating private member variables from each other Comment from : @andrewf8366 |
|
why theres a unity icons on an obj files? hmmm Comment from : @kiririn39m8 |
|
It's not a myth and you did not get it right Cherno Functions that defined in header CAN be inlined by compiler because definition of this function would be visible in each translation unit that includes that header and functions that only declared in the header can't be inlined because translation unit do not know body of the function Linker can inline functions across translation units if LTO is enabled but that is incredibly slow That's why unity builds rule XD Comment from : @glorioussir9673 |
|
I feel like the writer of this code would benefit greatly from turning up the warning level and/or just running a static analysis Go into the project settings and turn on Microsoft All Rules or clang-tidy and Run Code Analysis on file/project You don't have to fix every warning, especially the microsoft GSL recommendations are excessive, but you can learn so much from what they suggest eg making methods const and/or noexcept Comment from : @KX36 |
|
I only use mutable for mutexes to allow me to use them in const getters Comment from : @KX36 |
|
classes I put the variables at the bottom because I feel the public interface should come first, but structs I put them at the top because structs should be mostly POD Comment from : @KX36 |
|
The correct word for headers is "abstraction" Headers are an abstraction of the class In Java, you have interfaces (abstraction) That is the same as headers However, requiring it for every class is a pain in the ass Comment from : @ensabinha |
|
When it comes to inline, you can reference it with cppreference, following this link: ` w/cpp/language/inline ` Comment from : @TheMesoria |
|
inline keyword almost guarantees inlining You can view the source of gcc or clang and inline dramatically increases the inline "score" Comment from : @Jimmy9Bazooka |
|
I hope when you look at the variables, you talk about the packing of them I also wish you replied to comments :( Comment from : @aloluk |
|
He just keeps going and going and going and nothing will stop him until he got to the ground level lol Love it Comment from : @wuspoppin6564 |
|
I believe it is actually impossible to inline the function when it is in a different compilation unit It would HAVE TO be done by the linker So unless linker optimizations can do inlining, it is impossible Not sure if linker does inlining or not Comment from : @tomasruzicka9835 |
|
Your Java example makes no sense The thing that makes more sense is that on Java you were writing code for yourself and not other peoplebrI know for a fact the compiler can inline functions in the CPP My reason for not putting function bodies in headers is to speed up compilation Comment from : @aloluk |
|
What do you think cherno about CMake or Makefile? Comment from : @wcaleniekubaa |
|
Bless you, Cherno, for being so innocent and using "Team Deep" so nonchalantly Comment from : @ScorpioHR |
|
why getters such initialized() are non const? Comment from : @nmmm2000 |
|
How your visual studio look soo good , which theme is this Comment from : @ashutoshchar940 |
|
I think "the compiler more likely inlines functions in a header file" is just a myth The actual compiler, after the pre-processor, doesn't even know which part is from the h file and which is from the cpp, it's just a huge post-processed text blob But most header file function definitions are so simple that they get inlined; if they get too complex the linker forces the removal from the header file (double functions found) - so it's inverse logic that "header file definitions get inlined" Also, any public consumer of a class would pull class logic into its own code, which is just a bad design In our company, any function definition (even the simplest) is not allowed And we also don't stick to "every cpp must have a h file" -- mostly we have 1 header file for 1 class definition, and the class is split among 10-15 cpp files, each small and focused on a single class functionality group Comment from : @hopperpl |
|
Well "better header files" would be using modules instead of header files buuuut clang and gcc support for them is still experimental and so is cmake support Comment from : @sinom |
|
Hi Cherno Can i copy ur layer system? Comment from : @user-ib3gl6pj6h |
|
With gcc without -Os the 'inline' functions in the header file are most likely inlined It can speed-up the code Comment from : @ArjanvanVught |
|
As long as the file thats including the other file (imagine you include gameh) has access to the implementation of the code, it will inline it (at least in c) So if you include a header file with code, that code is always inlined As simple as that Comment from : @Charlyzard_ssb |
|
lol Comment from : @absorbingdude |
|
My theory for the declared functions in the header having more chances to be inline is that it is visible in other translation units if you define the function in a header file (and use something like __forceinline) and declare it on a cpp file, this inline function won't be visible on other cpp files Comment from : @guitarcat01 |
|
not bad Comment from : @iamadithedev |
|
;) Comment from : @oamioxmocliox8082 |
|
"Team deep" We all know cherno is not talking about his table tennis skills dang Comment from : @tharteon1866 |
|
Defining a function in the header (inline) makes it more likely to be inlined simply because it's definition is accessible in other translation units If the compiler compiles a file that includes the header containing that function and the body is not in there, it can't inline it, unless you enable link time optimization (LTO), which is usually pretty slow and only enabled for release builds But you can enable and should LTO for release builds, so while the remark makes sense, it's not very relevant Comment from : @allNicksAlreadyTaken |
|
Give us more raytracing!!! Comment from : @KaidenBird |
|
Also please please please if you're noticing you're not very consistent with your formatting; just use clang formatter Nothing worse than poorly formatted code you have to read all day Comment from : @DGMRuadeil |
|
1:33 I think part of the reason java can just do this is the built in javadoc support Even if there is not a lot of actual 'documentation' written the generated documents can be a great way to overview classes Comment from : @gwch3481 |
|
I do find myself wondering what happens if you inline a function which returns a private variable from a class Comment from : @logix8969 |
|
When it's inlined in the header, the compiled has a chance to inline it Otherwise the linker is the only component that can inline it brThis is why the LTO is popular Comment from : @adama7752 |
|
Nowadays, in Visual Studio 2022, you can hover over a macro and it gives you the option to expand it out to its evaluated state It is great for checking it is working as intended Comment from : @bencrabbe8549 |
|
first Comment from : @skjskj1773 |
|
let me bring some pop corns, your every video is like a treat <3 Comment from : @Skipper0x |
|
The Cherno is the GOAT Comment from : @EpicVideoGamer7771 |
|
Hello ! Here after 58 seconds of uploading 😂🙌🏻 Comment from : @spectre_xo |
Farming Simulator 19 | +100 METER HEADER !!! CRAZY AND LONG #ALFA VERSION РѕС‚ : Hüdaverdi Yılmaz Download Full Episodes | The Most Watched videos of all time |
#Find Hidden Web Files and Directories | Hidden Web Directories / Files search using Dirsearch РѕС‚ : Security - Red v/s Blue Team Download Full Episodes | The Most Watched videos of all time |
Woodworking Wisdom - Rasps, Files And Japanese Carvers Files РѕС‚ : Axminster Tools Download Full Episodes | The Most Watched videos of all time |
sony xperia z5 tips and tricks (secret codes,debugging,factory reset,hard reset,etc). РѕС‚ : Just Tech Download Full Episodes | The Most Watched videos of all time |
Files Recommendations on quality files u0026 Where to buy them РѕС‚ : Tom Walter Download Full Episodes | The Most Watched videos of all time |
Debugging Bitcoin Core with Fabian Jahr РѕС‚ : Chaincode Labs Download Full Episodes | The Most Watched videos of all time |
VS Code - Debugging РѕС‚ : Visual Studio Code Download Full Episodes | The Most Watched videos of all time |
Fix ADB Devices Not Shown|USB Debugging issue| Device is not listed in adb devices Camand| Miui8 РѕС‚ : Vinayak_Gundewadi_MD0584 Download Full Episodes | The Most Watched videos of all time |
Redirect URI Configurations for local Debugging in Azure App Registration РѕС‚ : Deep Dive Dotnet Download Full Episodes | The Most Watched videos of all time |
Infinix Hot 9 Play USB Debugging Mode РѕС‚ : Hard Reset Pedia Download Full Episodes | The Most Watched videos of all time |