Short introduction to header files in C

Поділитися
Вставка
  • Опубліковано 20 гру 2024

КОМЕНТАРІ • 89

  • @dawnald4846
    @dawnald4846 3 роки тому +73

    The best explanation i have found on the internet. Thank you!

  • @thisisibrokhim
    @thisisibrokhim 2 роки тому +6

    Spent 13:33 minutes and almost mastered the process of creating and using header files. Thank you!

  • @alexisthibodeau1300
    @alexisthibodeau1300 2 роки тому +13

    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

  • @metmay
    @metmay Рік тому +4

    these are the best c videos on the internet. thank you!

  • @marshmaker2873
    @marshmaker2873 10 місяців тому +1

    this is the best explanation for header files!

  • @Mushting
    @Mushting 2 роки тому +11

    Great video! Very informative and I like the way you deliver and explain things. Thanks so much

  • @rky-ke
    @rky-ke Рік тому +1

    watched this explicit video, and had to subscribe with immediate effect.

  • @bh3302
    @bh3302 Рік тому +2

    I was always confused about the difference between defining and declaring something. Thank you so much for making that clear.

  • @alessandropasqui6160
    @alessandropasqui6160 Рік тому +3

    Thank you for your clear and concise way of explaining such concepts!!

  • @samarthtandale9121
    @samarthtandale9121 Рік тому +1

    Your videos are truely so much valuable !!!

  • @santiagofonzo9336
    @santiagofonzo9336 Рік тому +1

    Crystal clear explanation! Thank you!

  • @AsifKhan-bt6kg
    @AsifKhan-bt6kg 9 місяців тому +1

    CODEVAULT YOU'RE THE CODE FOR THIS !!! THANK YOUUU

  • @KatarinaClaes-q1p
    @KatarinaClaes-q1p Місяць тому

    Damn, your videos are golden.

  • @flaviocampos3581
    @flaviocampos3581 3 роки тому +18

    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).

  • @shvideo1
    @shvideo1 3 роки тому +3

    Excellent detailed explanation. Thank you for this great video and taking the time to make it.

  • @lkwid9483
    @lkwid9483 3 роки тому +3

    Thank you so much for the explanation I've been looking for it all day

  • @codex8797
    @codex8797 3 роки тому +3

    Thanks man. Helped me a lot with my college project.

  • @Sakapaka
    @Sakapaka Рік тому

    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

    • @CodeVault
      @CodeVault  Рік тому

      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

  • @romagnolirojas10
    @romagnolirojas10 2 роки тому

    great video because you gave context to the solution of header files. TY

  • @jessamariemangubat406
    @jessamariemangubat406 4 роки тому +3

    Thank you so much Sir! Such a very big help

    • @CodeVault
      @CodeVault  4 роки тому +1

      Glad to be of help! Feel free to join our Discord server at discord.code-vault.net

  • @awaski977
    @awaski977 Рік тому +1

    Amazing explanation! Thanks a lot!

  • @victoramorim7650
    @victoramorim7650 Рік тому

    Just amazing! Great work!

  • @AnandRaj-ck2yw
    @AnandRaj-ck2yw 3 місяці тому

    please upload more videos on header files

    • @CodeVault
      @CodeVault  3 місяці тому +1

      I have one actually planned

  • @alialtan129
    @alialtan129 Рік тому

    It doesn't matter what the topic is, if CodeVault is explaining, I am understanding. Simple as

  • @totsh2056
    @totsh2056 2 роки тому +1

    how does the program know where to find the function definition / body?

    • @CodeVault
      @CodeVault  2 роки тому +1

      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

    • @totsh2056
      @totsh2056 2 роки тому

      ​@@CodeVault Thank you so much. This clears it up perfectly. Thank you.

  • @juniorrokudevelopertutoria3734
    @juniorrokudevelopertutoria3734 3 місяці тому

    Explanation is pretty good.

  • @nandorboda8049
    @nandorboda8049 7 днів тому

    You have to inculde the header file in both .c files, right?

  • @Antyelektronika
    @Antyelektronika 3 роки тому +1

    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

    • @CodeVault
      @CodeVault  3 роки тому +2

      Here's a list of them: www.cplusplus.com/doc/tutorial/preprocessor/
      You can do all sorts of things with preprocessor directives

  • @joshuablanchard6789
    @joshuablanchard6789 Рік тому

    your voice calms me

  • @salad5962
    @salad5962 2 роки тому

    Very comprehensive; many thanks.

  • @parrotparrot1948
    @parrotparrot1948 2 роки тому

    You earned yourself a subscriber :)

  • @satvikkapoor23859
    @satvikkapoor23859 2 роки тому

    Had to watch this video twice but it's clear now 👍

  • @gammyhorse
    @gammyhorse Рік тому

    Can you make a video about unity builds, how they work?

    • @CodeVault
      @CodeVault  Рік тому +1

      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)

    • @gammyhorse
      @gammyhorse Рік тому

      @@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.

  • @yassinemakhlouf9907
    @yassinemakhlouf9907 Рік тому

    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

  • @sageeuthanasia9324
    @sageeuthanasia9324 Рік тому

    Very helpful and very much appreciated

  • @李睿恩-f5x
    @李睿恩-f5x 3 роки тому

    Where is the video with how to share gobal varible between the files in the project?? I can't find it

    • @CodeVault
      @CodeVault  3 роки тому

      I don't think there is one yet. I'll look into it!

    • @xrguktmfpb
      @xrguktmfpb 3 роки тому

      You could use the `extern` keyword for declaring a global variable IIRC

  • @randomperson4321
    @randomperson4321 2 роки тому

    thank you so much ,amazing explaination

  • @afiqyahya3398
    @afiqyahya3398 2 роки тому

    Is there any video for your vs code confif?

    • @CodeVault
      @CodeVault  2 роки тому

      Yes, there is: code-vault.net/lesson/tv93s6yw9r:1610568955955

  • @incodewetrust8862
    @incodewetrust8862 Рік тому

    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 !

    • @CodeVault
      @CodeVault  Рік тому

      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

  • @ahmedgames9335
    @ahmedgames9335 10 місяців тому

    i get this error -> #error directive: "No Target Architecture"
    when i create a other c file in SourceFile Folder except main.c

    • @CodeVault
      @CodeVault  8 місяців тому

      I think you need to select the architecture that you are building for (x64 probably) in the project settings

  • @mykolazhabko3228
    @mykolazhabko3228 3 роки тому +1

    Thanks man! Helpful!!

  • @mohmmedfathy8093
    @mohmmedfathy8093 2 роки тому

    thank you very much for this explination

  • @arkemal
    @arkemal 2 роки тому

    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

    • @arkemal
      @arkemal 2 роки тому

      ps: stringsExample() is a function I'm calling from my main() function

    • @CodeVault
      @CodeVault  2 роки тому

      This video talks about exactly your issue: code-vault.net/lesson/il55l1ce8h:1642625255796

  • @amenkalai8442
    @amenkalai8442 Рік тому

    What is the ide you're using? is it visual studio?

    • @CodeVault
      @CodeVault  11 місяців тому

      Yes, it's Visual Studio Community edition

  • @aditim1064
    @aditim1064 3 роки тому

    Hey thanks for the video. It solved a query I had.

  • @sarthakssoni
    @sarthakssoni 9 місяців тому

    Best explanation

  • @sajolsajol8393
    @sajolsajol8393 2 роки тому

    Dude Thank You Very Much......
    Really Good......

  • @joeyb8006
    @joeyb8006 3 роки тому +1

    that was good thank you

  • @africanochan
    @africanochan 3 роки тому

    Thank you for explanation

  • @powergladius
    @powergladius 2 роки тому

    Legend

  • @eomith759
    @eomith759 3 роки тому +1

    Well explained! Thank you :)

  • @Ahmed_Elhaddad
    @Ahmed_Elhaddad 2 роки тому

    earned a sub

  • @ssahillppatell
    @ssahillppatell 8 місяців тому

    Thanks man

  • @babyzonechanell
    @babyzonechanell 2 роки тому

    thank you 👍

  • @tangerin511
    @tangerin511 8 місяців тому

    thank you

  • @hifa6205
    @hifa6205 3 роки тому

    thank you 🧡

  • @ronjeremy1232
    @ronjeremy1232 4 роки тому +1

    nice

  • @diegonayalazo
    @diegonayalazo 3 роки тому

    Thanks!

  • @RameenFallschirmjager
    @RameenFallschirmjager 4 роки тому +1

    the picture of yours occupying a big chunk of frame doesn't help at all!👎

    • @CodeVault
      @CodeVault  4 роки тому +1

      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

    • @RameenFallschirmjager
      @RameenFallschirmjager 4 роки тому

      @@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.

    • @CodeVault
      @CodeVault  4 роки тому +5

      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.

    • @SamSarwat90
      @SamSarwat90 4 роки тому +9

      @@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.

    • @magnuslundstrm3719
      @magnuslundstrm3719 4 роки тому +4

      I actually found the webcam very useful. Good stuff!

  • @dankhilkevich8559
    @dankhilkevich8559 8 місяців тому

    THANKS!