Re: 'warning: unused parameter'

Stephen Leake <[email protected]>
Newsgroups gmane.comp.version-control.monotone.devel
Message-ID <[email protected]>
Stephen Leake <[email protected]> writes:

> The code that generates this is in simplestring_xform.hh:
>
> template<> inline
> origin::type get_made_from<std::string>(std::string const & thing)
> {
>   return origin::internal;
> }
>
> 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?

-- 
-- Stephe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.