ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Is there a clang-format file for ROS 2?

asked 2019-06-07 10:55:39 -0600

rreignier gravatar image

I could not find a clang-format file to apply the rules found in the ROS 2 Developer Guide.

Does anyone know if such a file exists somewhere?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2019-06-07 10:58:51 -0600

Dirk Thomas gravatar image

The file is embedded in the ament_clang_formatpackage which provides the linter API / CLI:

edit flag offensive delete link more


I don't think it can be applied to our code base, but it is close.

William gravatar image William  ( 2019-06-07 18:03:07 -0600 )edit

answered 2019-06-07 18:02:24 -0600

William gravatar image

We have a tool for checking and apply style with clang format called ament_clang_format (CLI tool and cmake logic to make it an automated test). However, we do not test against this right now, and I don't think ament_clang_format can cleanly apply to our code standard, due to some limitations in clang format w.r.t. to wrapping of arguments.

@mjcarroll was looking at resolving this at some point but never finished.

As @dirk-thomas mentioned we have a style file in that package, but again, if you tried to check our code base with it there would be diff's.

The one we use right now is ament_uncrustify which uses uncrustify and a definition file there to check our style. We also use ament_cpplint which uses a patched version of Google's to do some additional style-like checks.

You can see the list of "default" linters here:

And you can see that for now clang_format is commented out.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-06-07 10:55:39 -0600

Seen: 1,766 times

Last updated: Jun 07 '19