Line 3: Line 3:
 
=Header Files=
 
=Header Files=
  
 +
In earlier classes, the function declarations and definitions were supposed to be before the main function. But if you have a large amount of code, that can get a little tedious.
  
 +
An easy way to get around that is by using different files.
  
 +
A header file is a ".h" file, like stdio.h.
 +
To make a header file, open an empty file with the following contents:
 +
 +
 +
(hash)ifndef EXAMPLE_H
 +
 +
(hash)define EXAMPLE_H
 +
 +
(function declarations here)...
 +
 +
(hash)endif
 +
 +
 +
 +
The function definitions can come in another ".c" file. where you need to include your header file.  To compile these files you need to make use of a Makefile.
  
  
  
 
[[ ECE264|Back to ECE264]]
 
[[ ECE264|Back to ECE264]]

Revision as of 05:23, 28 April 2011


Header Files

In earlier classes, the function declarations and definitions were supposed to be before the main function. But if you have a large amount of code, that can get a little tedious.

An easy way to get around that is by using different files.

A header file is a ".h" file, like stdio.h. To make a header file, open an empty file with the following contents:


(hash)ifndef EXAMPLE_H

(hash)define EXAMPLE_H

(function declarations here)...

(hash)endif


The function definitions can come in another ".c" file. where you need to include your header file. To compile these files you need to make use of a Makefile.


Back to ECE264

Alumni Liaison

Sees the importance of signal filtering in medical imaging

Dhruv Lamba, BSEE2010