Re: 'warning: unused parameter'
Markus Wanner <[email protected]>
| Newsgroups | gmane.comp.version-control.monotone.devel |
|---|---|
| Message-ID | <[email protected]> |
On 04/30/2014 11:19 AM, Václav Zeman wrote: > On 30 April 2014 11:05, Stephen Leake wrote: >> Stephen Leake <[email protected]> writes: >>> Stephen Leake <[email protected]> writes: >>>> Is there a way to mark 'thing' as unused? or do we have to disable that >>>> warning with -Wno-unused-parameter? >>> >>> I found three answers on stack overflow: >>> >>> 1) comment out or delete the parameter name: >>> >>> a) origin::type get_made_from<std::string>(std::string const & /* thing */) >>> >>> b) origin::type get_made_from<std::string>(std::string const & ) >>> >>> 2) cast it to void: >>> >>> (void)thing; >>> >>> I prefer 1a; it most clearly documents that we know there is a parameter >>> by that name, but we are not using it in this case. Any objections? I agree. >> In most uses of CMD_NO_WORKSPACE, "execid" is not used, but it is used >> in some (cmd_netsync.cc clone). Yeah, macros are problematic - not only in that regard. I'd generally like to see us move away from those, but... > You could special case GCC and introduce your own macro that expands > to the "unused" attribute in case of GCC: > http://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Function-Attributes.html#index-g_t_0040code_007bunused_007d-attribute_002e-3000 Special casing a compiler just to get rid of a warning sounds weird to me. How about other compilers? And changes between compiler versions? We'll end up cluttering our code with a lot of ifdefs if we go that route. That's not worth it, IMO. That being said, I certainly agree we should try to reduce compiler warnings as much as possible with generic ways. I started the branch nvm.cleanup-warnings for that work. But please keep focusing on fixing real issues for release 1.1, for now. Regards Markus Wanner _______________________________________________ Monotone-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/monotone-devel
signature.asc
(application/pgp-signature, 242 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iEYEAREDAAYFAlNiDBkACgkQsPwMloDjyo/UZgCeLaWZa7DcKrjf2z7NXW9gu/px HpUAnRXHX1dd0KGD73nab7M6cyZJDSV1 =5b4+ -----END PGP SIGNATURE-----