Barr Group FacebookBarr Group TwitterBarr Group LinkedInBarr Group Vimeo

Rules

The following C coding rules relate to the naming of modules:

Rule 4.1.a.) All module names shall consist entirely of lowercase letters, numbers, and underscores. No spaces shall appear within the file name.

Rule 4.1.b.) All module names shall be unique in their first eight characters, with .h and .c used for the suffix for header and source files respectively.

Rule 4.1.c.) No module name shall share the name of a standard library header file. For example, modules shall not be named stdio or math.

Rule 4.1.d.) Any module containing a main() function shall have the word main in its filename.

Reasoning

Multi-platform work environments (e.g., Linux and Windows) are the norm rather than the exception. To support the widest range, file names should meet the constraints of the least capable platforms. Additionally, mixed case names are error prone due to the possibility of similarly-named but differently-capitalized files becoming confused.

The inclusion of main in a file name is an aid to the maintainer that has proven useful. We adopted this rule after a consulting client showed us a project that had more than 200 source code files each containing its own variant of main().

Exceptions

None.

Enforcement

An automated tool shall confirm that all file names used in each build are consistent with these rules.

What’s happening and how it’s done. Get in the know.

Sign up for our newsletter today!

Receive free how-to articles, industry news, and the latest info on Barr Group webinars and training courses via email. 

To prevent automated spam submissions leave this field empty.