Functions

Other C language standards' pages:

Naming Standards
Abbreviations
C Language Standards

Prefix

If a function is defined in a header file, there's a possibility that its name may conflict with the name of another function defined elsewhere. To prevent these conflicts, all functions defined inside header files must have a prefix.

Functions defined inside implementation (.c) files don't need an inter-component or inter-module prefix. Functions defined inside .c files have file scope and any imported functions will have inter-component or inter-module prefixes, so naming conflicts are highly unlikely.

Also, if a function belongs to a specific type of object (e.g., class) in an object oriented interface, its prefix must have an additional object name part. The object name part of a prefix must start with a lowercase letter and must be separated from other parts of the identifier using underscores. If the object name is made up of multiple words, they must be separated using capitalization of the first letter of the second and subsequent words in the object name (e.g., ipRoute or simCard).

pool = le_mem_CreatePool(sizeof(MyObject_t), "My objects"); // This function doesn't belong to a class.
le_mem_pool_Expand(pool, numObjects); // This is one of the "pool" class's functions.
objPtr = le_mem_pool_Alloc(pool); // This also belongs to the "pool" class.
objSize = le_mem_block_GetSize(objPtr); // This function belongs to the "block" class.

Camel Case

After the prefix (if any), the rest of the function name should be in CamelCase, starting with an uppercase letter.

Verbage

Function names must contain a verb, because they are active. They should also contain an object, unless the object is obvious in the prefix.

To be consistent with Java conventions, the verb should come before the object, like this:

GetTimeRemaining(), le_mem_CreatePool(), and swi_timer_Start().