liveBook · Manning

Function declaration

As explained in Modern C, Third Edition

A function definition is a C construct that specifies a function's declaration and body.

A function declaration identifies a function, while a function definition adds the function body. In C, the declaration and the body together specify what the function does; the body is written as a compound statement enclosed in braces. section 2.1 section 2.3

A function definition

int main(int argc, [[maybe_unused]] char* argv[argc+1]) { ... } Here, the declaration begins with the return type and function name, includes the parameter list, and is followed by braces containing the function's code. The special function main must be present because it starts program execution. section 2.1 section 2.3

Keep these distinctions in view:

  • A declaration specifies the identifier and the kind of entity it refers to. section 2.3
  • A function has a definition when its declaration is followed by braces containing its code. section 2.3
  • The function body describes the operations the function is supposed to perform. section 2.1

How Modern C, Third Edition covers it

How deep it goes
Explains the distinction through declarations, return types, parameter lists, function bodies, and enclosing braces.
Examples
Uses main(void) and main with argc and argv to show declarations followed by executable function bodies.
What you can do after
Evaluate whether a function name has only a declaration or a complete definition containing a body.
How it connects
Connects function declarations with function definitions, function bodies, compound statements, and program execution.

Also explained in

Compare how 6 books explain function declaration →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.