Thread: What is the difference between makefile and a headerfile in C programming?

  1. #1
    Registered User
    Join Date
    Sep 2010
    Location
    Europe
    Posts
    87

    What is the difference between makefile and a headerfile in C programming?

    Hello. I study C.

    Question is already in the post title.

    I know that header files, such ones that I write, can be used for calling eg functions from an external file.

    Is that true? What is the makefile then?

    I am asking what is the difference and when should I use which one? (header file / makefile)

    I have learned online that there is a difference in the code:

    for the header:

    Code:
    #include "header.h"
    
    int main () {
      test();
      return 0;
    }
    and for the makefile:

    Code:
    #include <hellomake.h>
    
    int main()
    {
      myFunction();
      return(0);
    }
    some links:
    A Simple Makefile Tutorial
    https://en.wikipedia.org/wiki/Include_directive
    https://en.wikipedia.org/wiki/Makefile

    Thank you.
    Last edited by nerio; 12-23-2015 at 02:54 PM.

  2. #2
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    A makefile and a header file are completely different things. What you've posted is not a makefile at all! Did you even read the tutorial you linked to? Actually, that tutorial doesn't seem to be very good. I suggest reading the GNU make manual instead, especially chapter 2: GNU make

  3. #3
    Guest
    Guest
    A header contains C code that can be placed in another source file by using the #include directive.

    A makefile contains commands that usually call the compiler and linker with certain parameters to automate the creation of an executable. It does not use C or C-like syntax!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problems compiling C with libcurl headerfile
    By sandeep080 in forum Networking/Device Communication
    Replies: 6
    Last Post: 08-02-2011, 02:08 AM
  2. declaring a structure in another headerfile
    By ahming in forum C Programming
    Replies: 7
    Last Post: 04-05-2008, 04:39 AM
  3. difference makefile makefile.am makefile.in
    By Bargi in forum Linux Programming
    Replies: 7
    Last Post: 10-28-2007, 02:08 PM
  4. Does anybody know how can we use Java to prepare a C HeaderFile
    By arvindkr_1999 in forum C++ Programming
    Replies: 8
    Last Post: 04-28-2004, 03:16 AM
  5. C Headerfile problems
    By hireintelligence in forum C Programming
    Replies: 1
    Last Post: 03-02-2002, 12:45 PM