A naming standard gives identifiers a consistent pattern and separates two concerns: C's technical restrictions and the semantic conventions that make code readable. Apply one policy to every type, member, variable, enumeration, macro, and function. section 9.2
Use a naming standard to avoid collisions and clarify intent:
- Keep every identifier visible in a header file conforming to C's restrictions. section 9.2
- Treat reserved forms carefully: double underscores, an underscore followed by a capital letter, file-scope underscore names, predefined names, library names, and names ending in _t can conflict with the implementation. section 9.2
- Expose only interface types and functions, limiting pollution of the global identifier space. section 9.2
- Prefer names that remain recognizable, distinguishable, and quickly readable rather than merely legal. section 9.2 section 9.3
Reducing collisions in a function interface
Consider the declaration `double memory_sum(size_t N, size_t I, double strip[N][I]);`. `N` can invite a macro, `I` can conflict with the complex-number interface, `strip` can resemble an implementation name, and `memory_sum` could later acquire a standard meaning. A collision-resistant policy changes it to `double p99_memory_sum(size_t p00_n, size_t p00_i, double p00_strip[p00_n][p00_i]);`. The prefix limits exposure, while the longer names make the parameters distinguishable. section 9.2
1 double memory_sum(size_t N, size_t I, double strip[N][I]);
N is a capitalized identifier, and thus your collaborator could be tempted to define a macro N as a big number.
I is used for the root of – 1 as soon as someone includes complex.h.
The identifier strip might be used by a C implementation for a library function or macro.
The identifier memory_sum might be used by the C standard for a type name in the future.
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":1}],[{\"line\":2,\"ch\":28},{\"line\":2,\"ch\":29}],[{\"line\":0,\"ch\":4},{\"line\":0,\"ch\":10}],[{\"line\":0,\"ch\":22},{\"line\":0,\"ch\":28}],[{\"line\":0,\"ch\":22},{\"line\":0,\"ch\":28}],[{\"line\":0,\"ch\":4},{\"line\":0,\"ch\":10}]]"}
!@%STYLE%@!
Compare the risky declaration and its collision-resistant revision directly, including the identifiers that may conflict with macros, library names, or future standard names. section 9.2
Good names support literal implementation and obvious control flow: the structure of the C program should communicate what it does, without relying on excessive comments or obscure naming. section 10.2









