I spent 2 hours in class for this simple topic, still had no idea how to do header files and source files, or even understanding the difference between them. I found your video and undrstood it in 13 minutes... I think I found my new teacher here
Thank you ! I really like the way you explain things. Is it possible to make a video about Makefile? Using headers and stuff? (I still didn't get to that topic but will be my next one soon, once I finish the headers).
just want to confirm that i understand, basically when you run the code it compiles all of the .c files together, and the .h which you included lets say in main.c just tells the program that somewhere in the program (most likely in a different .c) exist the definition of the function which was declared in the .h
Something like that. First is the preprocessor that includes the .h files that we specified at the top. Then, each .c file gets compiled individually into a object file for any syntax errors (here some symbols might not be defined yet). Then, the linker comes along and links all the object files together and checks if all the symbols (varibles and functions etc.) are defined properly
It happens during compilation. Whenever you say: gcc main.c -o main It looks into main.c (and standard libraries) for the function body. If you have another .c file with function definitions then you would need to add it in that gcc command, like so: gcc main.c utils.c -o main The process is a bit more complex. GCC has two steps that it takes to achieve an executable, one is compilation (which happens for each .c files individually) that's where those declarations and header files are important and the second one is the linker process which basically links actual function declarations with definitions and everything else into one single executable. You can search for these terms to learn more: compiler vs linker, static linking, dynamic linking... I may make more videos on the topic
I understand that pragram is a preprocessor keyword, what else beside include and define we have?, and where I can find them, thank you for this informativ video
I don't think I will make a video on the subject. But maybe I will create a series about making a simple video game engine from scratch (although there are plenty other good videos about this already)
@@CodeVault That's awesome. Please do, even though there are plenty other videos, because your explanations are very clear. I would really like to see your thought process. Of course if you have the time. Anyway thank you very much for responding my question. Take care.
projet_folder | headerr_folder | file1.h,file2.h,file3.h src_folder | file1.c,file2.c,main.c Makefile if stdlib pr stdio or math.h in not include in file1.h or file2.h can't you se their function if file1.h and 2.h are not included in main undeclared variable first used in this function main line xx, if file1.h are included conflicting type previous declaration of variable ... it's painfull and hopeless !
C splits the definition and declaration of variables and functions into header and implementation files. These videos should help a bit understand why you're getting errors when including files that contain the definition of the same variable: code-vault.net/lesson/6d7531sjbg:1642359047453 code-vault.net/lesson/fjri9hcdte:1642359047479
Thanks for this explanation. I'm using VSCode. If I include the header file in my main.c file, I've got the error: Undefined symbols for architecture x86_64: "_stringsExample", referenced from: _main in main-17dc44.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) however, if include the .c file, it works fine. Any idea why? When using Xcode, I can include the .h file, but with vs code, I need the .c file
Hey! I'm sorry about that. I'm trying to not cover important parts with the webcam as much as possible. Where were you not able to see? I could help clarify things
@@CodeVault You are distracting! I didn't watch the video because of that. No hard feelings. I think when someone shows up during tutorials video is distracting and it's just bad taste. Look at other channels. The best youtubers who make tutorials like you never show themselves during video.
Alright, thanks for the feedback. I'll keep that in mind although, I don't think I'll change this style of videos as nobody else found an issue with this yet.
The best explanation i have found on the internet. Thank you!
Absolutely. Infact I am subscribing immediately
Spent 13:33 minutes and almost mastered the process of creating and using header files. Thank you!
I spent 2 hours in class for this simple topic, still had no idea how to do header files and source files, or even understanding the difference between them. I found your video and undrstood it in 13 minutes... I think I found my new teacher here
these are the best c videos on the internet. thank you!
this is the best explanation for header files!
Great video! Very informative and I like the way you deliver and explain things. Thanks so much
watched this explicit video, and had to subscribe with immediate effect.
I was always confused about the difference between defining and declaring something. Thank you so much for making that clear.
Thank you for your clear and concise way of explaining such concepts!!
Your videos are truely so much valuable !!!
Crystal clear explanation! Thank you!
CODEVAULT YOU'RE THE CODE FOR THIS !!! THANK YOUUU
Damn, your videos are golden.
Thank you ! I really like the way you explain things.
Is it possible to make a video about Makefile? Using headers and stuff? (I still didn't get to that topic but will be my next one soon, once I finish the headers).
I'll look into it
Excellent detailed explanation. Thank you for this great video and taking the time to make it.
Thank you so much for the explanation I've been looking for it all day
Thanks man. Helped me a lot with my college project.
just want to confirm that i understand, basically when you run the code it compiles all of the .c files together, and the .h which you included lets say in main.c just tells the program that somewhere in the program (most likely in a different .c) exist the definition of the function which was declared in the .h
Something like that. First is the preprocessor that includes the .h files that we specified at the top. Then, each .c file gets compiled individually into a object file for any syntax errors (here some symbols might not be defined yet). Then, the linker comes along and links all the object files together and checks if all the symbols (varibles and functions etc.) are defined properly
great video because you gave context to the solution of header files. TY
Thank you so much Sir! Such a very big help
Glad to be of help! Feel free to join our Discord server at discord.code-vault.net
Amazing explanation! Thanks a lot!
Just amazing! Great work!
please upload more videos on header files
I have one actually planned
It doesn't matter what the topic is, if CodeVault is explaining, I am understanding. Simple as
how does the program know where to find the function definition / body?
It happens during compilation. Whenever you say:
gcc main.c -o main
It looks into main.c (and standard libraries) for the function body. If you have another .c file with function definitions then you would need to add it in that gcc command, like so:
gcc main.c utils.c -o main
The process is a bit more complex. GCC has two steps that it takes to achieve an executable, one is compilation (which happens for each .c files individually) that's where those declarations and header files are important and the second one is the linker process which basically links actual function declarations with definitions and everything else into one single executable. You can search for these terms to learn more: compiler vs linker, static linking, dynamic linking... I may make more videos on the topic
@@CodeVault Thank you so much. This clears it up perfectly. Thank you.
Explanation is pretty good.
You have to inculde the header file in both .c files, right?
I understand that pragram is a preprocessor keyword, what else beside include and define we have?, and where I can find them, thank you for this informativ video
Here's a list of them: www.cplusplus.com/doc/tutorial/preprocessor/
You can do all sorts of things with preprocessor directives
your voice calms me
Very comprehensive; many thanks.
You earned yourself a subscriber :)
Had to watch this video twice but it's clear now 👍
Can you make a video about unity builds, how they work?
I don't think I will make a video on the subject. But maybe I will create a series about making a simple video game engine from scratch (although there are plenty other good videos about this already)
@@CodeVault That's awesome. Please do, even though there are plenty other videos, because your explanations are very clear. I would really like to see your thought process. Of course if you have the time. Anyway thank you very much for responding my question. Take care.
is it possible to include a header file with full path
if yes can you show me how both in windows and linux
thank you so much
I'll look into it
Very helpful and very much appreciated
Where is the video with how to share gobal varible between the files in the project?? I can't find it
I don't think there is one yet. I'll look into it!
You could use the `extern` keyword for declaring a global variable IIRC
thank you so much ,amazing explaination
Is there any video for your vs code confif?
Yes, there is: code-vault.net/lesson/tv93s6yw9r:1610568955955
projet_folder
|
headerr_folder
| file1.h,file2.h,file3.h
src_folder
| file1.c,file2.c,main.c
Makefile
if stdlib pr stdio or math.h in not include in file1.h or file2.h can't you se their function
if file1.h and 2.h are not included in main undeclared variable first used in this function main line xx, if file1.h are included conflicting type previous declaration of variable ...
it's painfull and hopeless !
C splits the definition and declaration of variables and functions into header and implementation files. These videos should help a bit understand why you're getting errors when including files that contain the definition of the same variable:
code-vault.net/lesson/6d7531sjbg:1642359047453
code-vault.net/lesson/fjri9hcdte:1642359047479
i get this error -> #error directive: "No Target Architecture"
when i create a other c file in SourceFile Folder except main.c
I think you need to select the architecture that you are building for (x64 probably) in the project settings
Thanks man! Helpful!!
thank you very much for this explination
Thanks for this explanation.
I'm using VSCode.
If I include the header file in my main.c file, I've got the error:
Undefined symbols for architecture x86_64:
"_stringsExample", referenced from:
_main in main-17dc44.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
however, if include the .c file, it works fine. Any idea why?
When using Xcode, I can include the .h file, but with vs code, I need the .c file
ps: stringsExample() is a function I'm calling from my main() function
This video talks about exactly your issue: code-vault.net/lesson/il55l1ce8h:1642625255796
What is the ide you're using? is it visual studio?
Yes, it's Visual Studio Community edition
Hey thanks for the video. It solved a query I had.
Best explanation
Dude Thank You Very Much......
Really Good......
that was good thank you
Thank you for explanation
Legend
Well explained! Thank you :)
earned a sub
Thanks man
thank you 👍
thank you
thank you 🧡
nice
Thanks!
the picture of yours occupying a big chunk of frame doesn't help at all!👎
Hey! I'm sorry about that. I'm trying to not cover important parts with the webcam as much as possible. Where were you not able to see? I could help clarify things
@@CodeVault You are distracting! I didn't watch the video because of that. No hard feelings. I think when someone shows up during tutorials video is distracting and it's just bad taste. Look at other channels. The best youtubers who make tutorials like you never show themselves during video.
Alright, thanks for the feedback. I'll keep that in mind although, I don't think I'll change this style of videos as nobody else found an issue with this yet.
@@CodeVault Don't listen to this fool (rameen). Clearly just being toxic. I dont find it distracting at all. Keep up the great work! Very appreciated.
I actually found the webcam very useful. Good stuff!
THANKS!