Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Compilation of a header file in c++

  1. May 28, 2009 #1
    Hi..am just learning c++...i have a doubt..

    Suppose you have a header file and you include it in your main program by using the #include directive..then do you have to compile the header file separately? Or does it get compiled with the main program?
  2. jcsd
  3. May 28, 2009 #2


    User Avatar
    Science Advisor
    Homework Helper

    Yes, all the #include does is copy the text of the header file into the .cpp file before passing it to the compiler
  4. May 28, 2009 #3
    I guess your yes means that one does not have to compile a header file separately...and it gets compiled with the main program..?
  5. May 28, 2009 #4
    I understand..thank you..
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Compilation header file Date
Creating a simple text parser/compiler Jun 28, 2017
C/++/# Trying to compile a source code in C Feb 14, 2017
Fortran77 data compiler problem Jan 19, 2017
Help in telling compiler to include header files for C Oct 27, 2016
C/++/# Visual Studio Code Compile C (or C++) May 5, 2016