Home Segments Index Top Previous Next

654: Mainline

Because definitions allocate memory, whereas declarations do not, you must ensure that your C compiler reads definitions only once. Otherwise, your program will not compile.

Complex programs, involving complex connections between multiple header files, may force your C compiler to read the same header file more than once during a compilation.

Consequently, you should keep definitions out of header files, which may be read more than once; there is no such prohibition against declarations.

Note that structure specifications and function prototypes are declarations, rather than definitions, although many people substitute the word definition for the word declaration when there is no special need to be precise. The trade-structure specification is a declaration, because it tells the C compiler only what memory to allocate when a trade object is created; it does not actually allocate any memory.