GCC C++ Coding Conventions

Status as of 2012-08-16: The C++ coding conventions for GCC have been approved. The contents of this page are now obsolete. Please visit the official GCC Coding Conventions page for details.

This is a proposed set of coding conventions to be used when writing GCC in C++. The intention is to develop this on the wiki, and move them to http://gcc.gnu.org/codingconventions.html when they are stable.

For some additional background information, please see RFC:Switching implementation language to C++

General Guidelines

C++ features

C++ Coding Conventions

   1 class my_class {
   2  public:
   3   my_class()
   4     : field1_(0), field2_(NULL_TREE)
   5   { }
   6 
   7   // Meaningful comment.
   8   int
   9   field1()
  10   {
  11     return this->field1_;
  12   }
  13 
  14  private:
  15   // Comment about field1.
  16   int field1_;
  17   // Comment about field2.
  18   tree field2_;
  19 };

   1 void
   2 very_long_class_name::very_long_function_name(
   3     very_long_type_name arg)
   4 {

   1 void
   2 very_long_template_class_name <with, a, great, many, arguments>
   3 ::very_long_function_name(
   4     very_long_type_name arg)
   5 {
  1. More precisely, any output which does not need to be internationalized or localized for a French or Chinese GCC user; and dump output is in that case (and a Gimple textual output also would be in that case). (1)

None: CppConventions (last edited 2013-08-04 08:43:34 by JanusWeil)