Pages

Wednesday, February 18, 2015

Why header file?

Header file in a program will comprise of the files, function definitions and macros. Basically we will give same name for the c (or cpp file) and its corresponding header file. Like "ExInit.c" and "ExInit.h" file. So in this example, the preprocessor macros and functions that are used in the "ExInit.c" will be included in the "ExInit.h" .

Why we are using header file is a question since we can declare it in the c file itself. So what I found out from my experience is follows:

  1. Easy review since it is a structured one.
  2. To include in multiple file same group of files,functions or macros.
  3. To include inbuilt library of the c compiler.
  4. To reduce the code size by making proper conditional preprocessor statements.
  5. To improve compilation time.

No comments:

Post a Comment