liveBook · Manning

Naming prefix

As explained in Modern C

A naming prefix is a distinctive initial sequence added to identifiers to reduce naming conflicts and indicate an interface or subsystem.

A naming prefix is a distinctive initial sequence added to identifiers to reduce naming conflicts and mark an interface or subsystem. Exposing fewer global names lowers the chance that application code, libraries, macros, or future standards will collide. section 9.2

Prefixing an interface and its parameters

Instead of declaring double memory_sum(size_t N, size_t I, double strip[N][I]), use double p99_memory_sum(size_t p00_n, size_t p00_i, double p00_strip[p00_n][p00_i]);. The p99_ prefix identifies public API names, while p00_ marks internals and prevents collisions involving macros, parameter names, or structure members. section 9.2

How Modern C covers it

How deep it goes
Explains prefix selection through declarations, macro hazards, structure members, and parameter names, but defers inline functions and macros.
Examples
Uses pthread_, p99_, P99_, p00_, P00_, and prefixed array-function declarations.
What you can do after
Apply it by prefixing public and internal identifiers to reduce collisions across interfaces, parameters, members, and macros.
How it connects
Connects naming prefixes with identifiers, APIs, macros, structure members, function parameters, and the POSIX thread API.

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.