Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Eclipse / Emacs auto formatter style following the google style guide instead of ROS #8

Closed
simonlynen opened this issue May 6, 2013 · 1 comment

Comments

@simonlynen
Copy link
Contributor

ROS and google are quite similar.
http://google-styleguide.googlecode.com/svn/trunk/eclipse-cpp-google-style.xml
http://www.ros.org/wiki/IDEs?action=AttachFile&do=view&target=ROS_format.xml

Main difference:
Indentiation in spaces: ROS: 4, Google: 2 (I vote for Google)
Curly bracket on new line for conditionals: ROS: yes, Google: no (I vote for Google)
Initializer list break: ROS: no, Google: yes (I vote for ROS)

ROS:

/*
 * A sample source file for the code formatter preview
 */
#include <math.h>

class Point
{
public:
  Point(double x, double y) :
      x(x), y(y)
  {
  }
  double distance(const Point& other) const;

  double x;
  double y;
};

double Point::distance(const Point& other) const
{
  double dx = x - other.x;
  double dy = y - other.y;
  return sqrt(dx * dx + dy * dy);
}

I would vote for Google which formatted the following example:

/*
 * A sample source file for the code formatter preview
 */
#include <math.h>

class Point {
 public:
  Point(double x, double y)
      : x(x),
        y(y) {
  }
  double distance(const Point& other) const;

  double x;
  double y;
};

double Point::distance(const Point& other) const {
  double dx = x - other.x;
  double dy = y - other.y;
  return sqrt(dx * dx + dy * dy);
}
@simonlynen
Copy link
Contributor Author

lets got with the google one as it saves space

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant