RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.16k stars 1.24k forks source link

Require semicolons on statement-like macros #21603

Closed jwnimmer-tri closed 5 days ago

jwnimmer-tri commented 1 week ago

This is a breaking change in case users were calling these macros themselves, they will need to make sure the semicolons are used in their own code.


Macros that do things semicolon-like should enforce that the user places a semicolon on at the end, at the call site. Currently in the code, calls to these macros sometimes have the semicolon at the call site and sometimes do not.

This idea aligns with the classic do-while-zero trick, though here for macros that are declarations or definitions (instead of statements), we don't need the do-while.

Uniformly having the semicolon is both easier to read (both for us, and IDEs / syntax highlighters), and makes it easier for the macro maintainers (me) to change the implementation without breaking call sites.

This has been on my list of things to clean up for a while now. It finally became more relevant now that I'm changing the default-scalars macros to allow for separate compilation per-scalar (so that compiling MbP isn't so awful).

Towards #21605 and therefore towards #20545.


This change is Reviewable

jwnimmer-tri commented 2 days ago

FYI Adjusting the release notes tag to not be "breaking" now, per #21634.