CHAPTER 21

image

Headers

As a project grows it is common to split the code up into different source files. When this happens the interface and implementation are generally separated. The interface is placed in a header file, which commonly has the same name as the source file and a .h file extension. This header file contains forward declarations for the source file entities that need to be accessible to other compilation units in the project.

Why to Use Headers

C requires everything to be declared before it can be used. It is not enough to just compile the necessary source files in the same project. For example, if a function is placed in func.c, and ...

Get C Quick Syntax Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.