liveBook · Manning

Naming policy

As explained in Modern C

A naming policy is a consistent set of rules governing how program identifiers are formed and selected.

A naming policy is a consistent set of rules for identifiers. Separate technical restrictions from semantic conventions, and apply the policy to types, members, variables, enumerations, macros, functions, and function-like macros. TAKEAWAY: Choose one consistent naming policy for all identifiers. section 9.2

A practical C naming policy should:

  • Keep every identifier visible in a header file conforming, because headers and macro definitions can interact unexpectedly. section 9.2
  • Respect reserved forms, including names beginning with an underscore and a second underscore, a capital letter, or other reserved patterns. section 9.2
  • Avoid global-space pollution by exposing only types and functions that belong to the application programming interface. section 9.2

How Modern C covers it

How deep it goes
Defines technical restrictions and semantic conventions, then applies selected C rules without cataloguing every reserved identifier.
Examples
Uses memory_sum declarations, collision-prone names, and a table comparing recognizable and distinguishable identifiers.
What you can do after
Practice/perform consistent C identifier selection, header hygiene, reserved-name avoidance, and limited interface exposure.
How it connects
Connects identifiers with macros, header files, reserved names, namespaces, and application programming interfaces.

Also explained in

Compare how 2 books explain naming policy →

Related concepts

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