You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Impala C++ Code follows a modified version of the Google C++ Style Guide at:

https://google.github.io/styleguide/cppguide.html

There are some key differences which are documented here.

Header Files

  1. Separate inline headers: We allow putting inline functions in separate files, using the suffix -inline.h or -impl.h or .inline.h

Scoping

  1. namespaces the using namespace directive is encouraged in .cc files
    1. Pros: reduces code volume
    2. Cons: pollutes the namespace, causes conflicts, makes it more difficult to determine the type of an object

Functions

  1. default function arguments we use default function arguments
    1. Pros: clean syntax, reduced code volumne
    2. Cons: function pointers are confusing in the presence of default arguments

Formatting

  1. Line Length We use 90 character line lengths
  2. TODO Comments we do not include the name in the TODO comment
  3. Function Declaration we line wrap differently than google, for example do:
// Google Recommends:
ReturnType LongClassName::ReallyReallyReallyLongFunctionName(
    Type par_name1,  // 4 space indent
    Type par_name2,
    Type par_name3) {
  DoSomething();  // 2 space indent
  ...
}
// we use:
ReturnType LongClassName::ReallyReallyReallyLongFunctionName(
    Type par_name1, Type par_name2, Type par_name3) { // 4 space indent
  DoSomething();  // 2 space indent
  ...
}
// Google Recommends:
ReturnType ClassName::ReallyLongFunctionName(Type par_name1, Type par_name2,
                                             Type par_name3) {
  DoSomething();
  ...
}
// We use
ReturnType ClassName::ReallyLongFunctionName(Type par_name1, Type par_name2,
    Type par_name3) {  // 4 indents
  DoSomething();
  ...
}

    3. Conditionals we format conditionals as follows

// Google Recommends:
if (x == kFoo) return new Foo();
if (condition)
  DoSomething();  // 2 space indent.
if (condition) {
  DoSomething();  // 2 space indent.
}
// we only use:
if (x == kFoo) return new Foo();  // If the whole line fits into the 90 character limit
if (condition) {
  DoSomething();  // Otherwise, 2 space indent.
}
  • No labels