Skip to content
UPEEC

Functions and Modules in C

Declaring, defining and organising functions across files — prototypes, headers, linkage and storage. Call by value/reference and storage classes have their own pages earlier in this subject.

Easy
Comments 0

This is an overview — pick a sub-topic below.

Sub-topics (14)

Arguments and Parameters

Parameters are the variables in the definition; arguments are the values passed in a call.

Beginner♥ 0🔖 0💬 0

Pass by Value

C always copies argument values into parameters.

Beginner♥ 0🔖 0💬 0

Recursion in C

A function calling itself, with a base case to stop.

Easy♥ 0🔖 0💬 0

Variadic Functions

Functions taking a variable number of arguments, like `printf`, using `stdarg.h`.

Intermediate♥ 0🔖 0💬 0

Inline Functions

`inline` suggests replacing calls with the function body; `static inline` in headers is the common safe pattern.

Intermediate♥ 0🔖 0💬 0

Header Files

`.h` files share declarations (prototypes, types, macros, `extern` variables) between source files.

Beginner♥ 0🔖 0💬 0

Include Guards

Prevent a header's contents from being processed twice.

Beginner♥ 0🔖 0💬 0

Separate Compilation

Each `.c` file compiles to an object file; the linker combines them.

Easy♥ 0🔖 0💬 0

Linkage

Whether a name refers to the same entity across files: external, internal or none.

Intermediate♥ 0🔖 0💬 0

Storage Duration

How long an object lives: automatic (block), static (whole program), allocated (malloc/free) or thread (`_Thread_local`).

Easy♥ 0🔖 0💬 0

Scope

Where a name is visible: block, file, function (labels) or prototype scope.

Beginner♥ 0🔖 0💬 0

External and Static Linkage

`extern` declares something defined in another file; `static` hides a file-level name from other files.

Easy♥ 0🔖 0💬 0

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.