GNU's C code writing specification, C language father Dennis Ritchie personally revised 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 Reference 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 pattern: for nonstardard names Appearing in st andard 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't use names In The Same Scope That Difer Only In The Prefix, Eg_S_top and _m_top. See Badnames for A List of Forbidden Names. (The Most Tempting of these Seem to BE and "and" __sz "
Names Must Never Have "__" 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 -Liners. Int one_line () {return 0} {Return Strchr (arg, 'a');} inline int three_lines (); // inline, but defined Below. // Note Indentation Template