This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
style convention: /*foo_p=*/ to annotate bool arguments
- From: Martin Sebor <msebor at gmail dot com>
- To: GCC Mailing List <gcc at gcc dot gnu dot org>, Jeff Law <law at redhat dot com>, Jason Merrill <jason at redhat dot com>
- Cc: Aldy Hernandez <aldyh at redhat dot com>
- Date: Mon, 3 Oct 2016 17:48:48 -0600
- Subject: style convention: /*foo_p=*/ to annotate bool arguments
- Authentication-results: sourceware.org; auth=none
In a recent review Jason and I discussed the style convention
commonly followed in the C++ front end to annotate arguments
in calls to functions taking bool parameters with a comment
along the lines of
foo (1, 2, /*bar_p=*/true);
I pointed out to Jason that in another code review, Jeff asked
to remove the same comment from the middle-end [1]. In the
interest of consistency Jason and I thought I should bring this
up for discussion so we can all be clear on whether or not this
is something worth standardizing and documenting.
As a separate question, in the same discussion I mention to Jason
a convention that I myself have found useful where the value of
a default argument is indicated in a comment in a function
definition that is declared elsewhere to take one, e.g., like so:
// In some header:
void foo (int, int, bool = -1);
// In some .c file:
void foo (int x, int y, bool bar_p /* = false */)
{
...
}
Jason thought this would be a good convention. Is there any
interest in/support for adopting it?
Thanks
Martin
[1] https://gcc.gnu.org/ml/gcc-patches/2016-08/msg00354.html
[2] https://gcc.gnu.org/ml/gcc-patches/2016-09/msg01469.html