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);
}
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:
I would vote for Google which formatted the following example: