 Okay, I'm back here again with James and noisy Sarasota again. I apologize for any background noise We have going on or any dogs that might run by And in the last video we were talking about Great for this truck to pass by We were wait we were talking about C programming which is something I've dabbled in wish I knew more about and you're way more experienced and more knowledgeable than I am compared to me Okay, which isn't saying much And we were talking about pointers and I asked you about how how does it know What block of memory is free for its right to for pointers? And you gave a quick overview of it, but really that's something that the programmer That the the fine details you don't have to worry about because that's pretty much taken care of by the operating system I so yeah, yes, yes, and so like for Unix operating system You know a fun thing to do is so a couple fun experiments and see You know one thing is that you're gonna call that your standard libraries all the time and you know standard libs standard. I oh and You can find those header files You probably find the source files online. I don't think the source files are on your operating system Because I think they're already compiled as as lib files, which you can't read it's binary But the header files exist so you can find those header files They're they're in your in your lip. I think with Debbie and there are Source I could be wrong about this like you can download if you download the development like I think it doesn't Yeah, yeah, I mean, yeah, I mean you get this. Oh, I mean, I don't know for each operating system Yeah, but all I'm saying is you get the header files and the header files is supposed to have all the all the interesting public information about that that extra functionality that you're gonna call and So you can you can actually look at that and that's going to call another library file Which which is probably not anything you would ever call yourself It's probably very system dependent and you can look at that and it's going to call another one and another one And you can kind of go down the rabbit hole and see how something that's that's the standard C libraries Start calling more and more operating specific library files but Another neat thing to do too is Every time you compile a C File which by the way, what's your favorite compiler? I just use GCC. I don't know if I have a favorite I just use yeah, yeah, yeah, I didn't know if there were favorites on that one But yeah, I mean there are different ones and I know I know there are different like you can use G plus plus right. Yeah, you can pile C and it's not the same compiler, right? No, no, no, yeah, and then there are things that are compile specific Each compiler does things a little bit different and I've come across that. Yeah Yeah, so so So it could matter but but for the most part you shouldn't have to worry about that But when you compile the first thing that happens to the the first thing the compiler does is it runs something called the the Pre-processor, okay, so what that does is you know every time you you run Include or anytime you type include this library what actually happens is that the pre-processor actually grabs that file and Injects it and so before anything gets compiled it converts it basically into one giant file So it's a fun experiment the next time you write something to see if you want to see like every single line of code necessary for that to run I believe it's CPP is the command on on Linux operating system just run CPP on on your main file and And maybe pipe it to less, you know And just start going through all the stuff they got called all that dependency chain You know just you know obviously look for it to too long You'll give yourself a headache, but just to see where all that stuff comes from and it's very interesting it's an interesting experiment and I actually knew somebody who They they were writing a program where they had to have all these configuration files and They were writing a C program that would take those configuration files And actually the first thing it would do is it would just take all these configuration files That included each other and it would run CPP on them and convert it to one file that he could start to parse I mean, you know, it's just an interesting way to do it instead of having to find all the files Just one file would start including all right. So now am I correct? I believe I'm correct in saying this With compiler you're taking your C code. It's compiling it and Then it basically turns it into assembly correct, and then it assembles it am I I feel like I've read that yeah, I think you're right, okay And we're getting in that territory where I feel comfortable Saying that is true among friends, but I don't know if I'm willing to publish it live for the web I'm pretty sure I read it Everything has to be assembled eventually so you can pile or the compiles into an assembly and then it assembles it Because the assembly language is like is is the computer specific? Yes Hardware different operating system it all has to be written different and then and then that computer can then Always take the assembly and convert it to the binary for that for that correct setup from my understanding yeah, because I recently I think I mentioned the last video I was talking with a C programmer in my IRC channel and I was talking he was Telling me that you know in my videos I say that when you're programming for the most part if you're programming properly It shouldn't matter what operating system you're on or what hardware you're running on whether it's an arm processor Or an x86 processor Use compile and I mean and I feel that's true for C Because everything I've tried to do I've been able to do that. I've cross compiled for Windows I've crossed compiled for arm processors on my desktop Maybe once you get more advanced than I am but that's how I feel everything I've tried to accomplish And I don't know what I'm doing So I feel like someone who does and he was like it's not as easy as you may think it is not easy Horribly difficult and see but I mean that's that's ideal Ideally you should if you're gonna write something like a C library. That's an important C library That's not that's not operate your operating system specific You should write it in a way that it can function on any right well my argument to that is there's Basic parts of the program and you can completely disagree with sure yeah That that's just see like calculating numbers adding things together creating variables. Oh, that's gonna be the same regardless the parts that become Not compatible from operating system to operating system is when you're really trying to interact with that operating system itself Which I know you're always really running on top of it So you're always interacting with it, but for example the example that guy gave in the IRC channel was Write a program that tells me how many characters why the terminal screen is Okay, and I Did yeah, and I sent you my second version of the code the first one was horrible The second one was horrible I was waiting for you to give me a little better way of doing it And yeah, I pretty much had to write code for both of them But then put them in in one program and then when I can compile and you wrote that code Well, I just didn't like the places you put things sure I was just gonna move things around but the way you wrote It's perfect So it was like five lines of code for how it's done in windows and five lines of code how it's done in Linux And then the compiler when I'm compiling it goes. Oh, he's compiling for Linux, right use this function he's compiling for windows use this function and so yeah, it's extra code but Lots of times you have libraries that do that sort of thing and there might be a library that Well, I mean that's the point and this kind of goes back to something else. We were talking about Everything you write should do one thing really well, right? So if if your objective is to write something that can determine the width of the terminal screen You can make a library file that that can be compiled for any operating system Because you wrote it flexible enough so that it can be caught the compiled for each Unfortunately the way C works is once you compile that is compiled for that operating system, right? But you write the source, right so that the way it compiles it is for the particular operating system You're compiling for right and then you can you can actually compile it as a library and from then on No matter what you write that you want to find the width of the terminal you now have this One library you can call that has been compiled in different ways so that the function with the same interface The same function call will return you the thing right that you want and so again my argument was to him And I think he was surprised how fast I did that it took me a little I really had no clue I was doing I googled how to do it one way and how to do it the other and you're so smart Chris well well I He I well he was trying to stump me is what I do and my kind of point is I don't know what I'm doing And I was still able to accomplish it and it may not have been the best way But now I have yeah that I put it in a header file which may have not I don't know if that's the best way to do it I've never never created a file for that and but now any time I need to do that I can just use that file I already wrote and it just spits out a number but back to my original argument is Yeah, you're saying oh a different operating system It goes a different way of getting different with that's because you're interacting with a different program You're interacting with the windows terminal or the Linux shell and it's like you're asking that program So it's not that an operating system really think it's just that you're communicating with a different program And so that's more of an aspect. I think in that particular case, but the simpler argument I have with that is with the Very simple you want to write a program that changes your window your desktop background Well, you have your Linux desktop background and you might have different desktops Although I think a lot of them have kind of merged in the way they do them or you have your it's like Yeah, you're gonna have to write different because you're interacting with a probe a different program You're not just writing one plus one equals two But again you do one thing well, right? And so if you write something that changes your desktop and maybe you can you can start by writing something Well, it only works if I'm running KDE But then you say, okay Well, I know how to check what desktop is somebody because I know there's this place check And now I'm gonna write it so that it checks those two places and and or three places or whatever it is And then when you got all the you know when you have all the Linux versions even when we move on the windows and Matt and so in theory Yeah, you could eventually write one program I don't know why you'd need to write a program that changes the desktop But in our theoretical idea you can write one program that does one thing really well is yeah Most of it is basically you write in a lot of lines of code that just basically makes decisions Based on which is what libraries do and absolutely so anyway again. I thank you for joining me today I thank you guys for watching. Please visit films by Chris comm That's Chris with the K There should be a link in the description of this video if you're watching it on YouTube and as always I hope that you have a great day not much I can do I know it looks like a garden, but it's a noisy Okay, this is an introduction to films by Chris comm I'm Chris. That's Chris the K That's me right there my daughter ember and my wife Jennifer We pretty much live in the swamps of Florida I'm a firefighter by day as well as by night. We work long hours, but that's not why you're here You're here about the videos. I put up on YouTube These videos are mainly about computers and Programming which means most of my videos look something like this And if that's what you're interested in great if not, that's all right I do videos on other topics too such as video editing special effects photo editing 3d design and music creation If you are one of my viewers and you enjoy my videos my patreon page is a place we can go to help support my videos So I asked that you take the time to go to my patreon page and look at different levels of rewards You can receive for different levels of backing there should be a link in the description of this video if you were watching it Otherwise you can visit patreon.com forward slash Metal X 1000 and I thank you for your time and your support Have a great day