C Standard Library Style Guidelines Draft 1999-02-26 ----------------------------------- This Library is written to appropriate C coding standards As such, it is intended to precede the recommendations of the GNU CodingStandard, which can be referenced here:. http: //www.gnu.ai.mit.edu/prep/standards_toc.html ChangeLog entries for member functions should use theclassname :: member function name syntax as follows: 1999-04-15 Dennis Ritchie
. It identifies the parentheses as the function-call operator or declarator, as opposed to an expression or other overloaded use of parentheses.04. Template function indentation template
{} 08. Try / Catch Blocks Try {//} catch (...) {//} - NOT- Try {//} catch (...) {//} 09. Member Functions Declarations and Defintions Keywords Such . as extern, static, export, explicit, inline, etc go on the line above the function name Thus virtual int foo () -NOT- virtual int foo () Reason: GNU coding conventions dictate return types for functions are on a separate line than the function name and parameter list for definitions. for C , where we have member functions that can. be either inline definitions or declarations, keeping to this standard allows all member function names for a given class to bealigned to the same margin, increasing readibility .10. Invocation of Member Functions with "this->" for non-uglified names, user this-> name to call the function. This-> sync () -not- sync () THE LIBRARY CURRENTLY HAS A MIXTURE OF GNU- C and Modern C CodingStyles. The GNU C Usages Will Be Combed Out Gradually.Name Patterns: for Nonstandard Name s appearing in Standard headers, we are constrained to use names that begin with underscores This is called "uglification" .The convention is:. Local and argument names: __ [az] * Examples:. __count __ix __s1 Type names and template formal- argument names: _ [AZ] [^ _] * Examples:. _Helper _CharT _N Member data and function names: _M _ * Examples:. _M_num_elements _M_initialize () Static data members, constants, and enumerations:. _S _ * Examples: _S_max_elements _S_default_valueDon ' THAT DIFFER ON THE SAME Scope That Difer Only in The Prefix, Eg_Top and _m_top. See Badnames for a list of forbidden name. (The Most Tempting of these Seem to be and "_t" and "
__sz ".) Names Must Never Have" __ "ITENALLY; It Would Confuse Nameunmanglers on Some Targets. Also, Never USE" __ [0-9] ", Same Reason. ------------- ------------- [by example] #ifndef _header_ # define _header_ 1namespace std {class gribble {public: // ctor, op =, dtor gribble () throw (); Gribble (Const Gribble & ); explicit gribble (int __howmany); gribble & operator = (const gribble &); virtual ~ gribble () throw (); // argument inline void public_member (const char * __arg) const; // in-class function definitions should be restricted To one-line (incount) {Return Strchr (arg, 'a');} inline int three_lines (); // inline, but defined Below. // Note Indentation Template