
A long time ago I read a post that mentioned a standard way to disable unused variable warnings in boost. Specifically this one: http://tinyurl.com/2o4ovh Although a trivial utility it seems generally useful to me and I was wondering if it existed in boost as a utility somewhere. It seems silly to recreate that function every time you need to disable such a warning. Thanks, Michael Marcin

Michael Marcin wrote:
A long time ago I read a post that mentioned a standard way to disable unused variable warnings in boost. Specifically this one:
Although a trivial utility it seems generally useful to me and I was wondering if it existed in boost as a utility somewhere.
It seems silly to recreate that function every time you need to disable such a warning.
Dave suggests two possibilities - and I prefer the second, plus a comment: void f( int /*unused*/ ) Which does not instantiate a template and is a clear and documented way to show that you really meant to have a parameter which is not used. As a third option, we could add #define BOOST_UNUSED_PARAMETER and use it like this: void f( int BOOST_UNUSED_PARAMETER ) just in case you want to avoid block-comments in your code. Regards, Daniel

Le samedi 28 juillet 2007 à 09:47 +0200, Daniel Frey a écrit :
Which does not instantiate a template and is a clear and documented way to show that you really meant to have a parameter which is not used. As a third option, we could add
#define BOOST_UNUSED_PARAMETER
and use it like this:
void f( int BOOST_UNUSED_PARAMETER )
just in case you want to avoid block-comments in your code.
I would suggest going a bit further and have: #define BOOST_UNUSED_PARAMETER(x) void f(int BOOST_UNUSED_PARAMETER(meaningful_name)) so that the Doxygen-generated documentation (e.g. for BoostBook and QuickBook) contains meaningful parameter names, once we add the following line to Doxygen's configuration file: PREDEFINED = BOOST_UNUSED_PARAMETER(x)=x Best regards, Guillaume
participants (3)
-
Daniel Frey
-
Guillaume Melquiond
-
Michael Marcin