3.1.1 Name mangling

As C does not have class or namespace concepts, a different mechanism must be used to indicate that a function should be considered an operation that is part of a class. Different classes often have operations that share the same name, especially if they implement the same interface, and it is essential that two operations may exist in the same project without causing name conflicts.

One solution, employed here and which ensures that C function names are unique, is to derive the function name from the class name and the operation name, joined together by an underscore character. The data() operation of the BinaryTreeNode class thus becomes BinaryTreeNode_Data().

This is a form of manual name mangling (also called name decoration). Name mangling is often used by compilers targeting native code to encode additional information about a function as part of its runtime name. The information encoded depends on the calling convention used, and may include, for instance, information on the arguments and return value of a function. Name mangling can be used to encode data not recognized by traditional file formats for executable files and the tools that operate on them (such as linkers). The mangling of compile-time names used here ensures that there are no naming conflicts and adds the name of the class as an aid to human developers.