Boost logo

Boost :

Subject: Re: [boost] [accumulator] A lot of unused "parameter" warnings
From: Roland Bock (rbock_at_[hidden])
Date: 2011-10-03 02:28:29


On 10/02/2011 03:59 PM, Vicente Botet wrote:
> Roland Bock-2 wrote:
>> On 10/01/2011 08:51 PM, Vicente J. Botet Escriba wrote:
>>> Le 01/10/11 20:03, Eric Niebler a écrit :
>>>> On 10/1/2011 9:29 AM, Vicente J. Botet Escriba wrote:
>>>>> Would you accept a patch that resolve them by commenting the
>>>>> parameter name?
>>>> Patches gladly accepted. Just open a ticket on svn.boost.org and
>>>> attach the patch. Thanks!
>>>>
>>> Well, I have reached to remove the warnings in Boost.Parameter and
>>> Boost.Fusion.
>>>
>>> The warnings in Boost.Accumulators are related to static variables
>>> included in a unnamed namespace such as
>>>
>>> ../../../boost/accumulators/numeric/functional_fwd.hpp:187:38:
>>> warning: unused variable 'min_assign' [-Wunused-variable]
>>> extern op::min_assign const &min_assign;
>>>
>>> Unfortunately, I don't know how to silent these warnings :(
>>>
>>> Have you an idea how to silent them?
>>>
>>> Best,
>>> Vicente
>>>
>> I had the same problem with some other library. I used the following
>> method to silence the warnings (replaced namespaces):
>>
>> namespace boost
>> {
>> template<class T> void touch(const T&) {}
>> }
>>
>> #define BOOST_TOUCH_FUNC(WHAT) \
>> namespace\
>> {\
>> template<class T> void touch_WHAT()\
>> { boost::touch(WHAT); }\
>> }
>>
>> #define BOOST_TOUCH_VAL(WHAT) boost::touch(WHAT);
>>
>>
>> If you find that useful, too, maybe it could be added to boost utility?
>> There is similar stuff in some libraries, but none of it is documented, I
>> think.
>>
>>
> I'm not sure I understand. You mean that one way to silence extern variable
> variables is to use them, isn't it?
> Are you suggesting that I add this kind of code to my programs or that the
> library author could add it on the files including extern declarations?
> Can someone explain me why the compiler is warning on this case?
>
> Best,
> Vicente
Right. This kind of "usage" will be optimized away, though.

Whether you or the library author have to do it, I don't know. Would be
nicer, if the author could do it, I guess.

To my understanding, the compiler just notifies you that you might have
forgotten to remove some obsolete code.

With gcc, you can also disable the warning via a pragma, btw.

Regards,

Roland


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk