
"drkm"
Unless I'm missing something, this should do the trick:
g++ -c -O2 -Wall -Wno-unused-variable foo.cpp
Ok, I found the solution. I was looking for a pragma to do it, but the solution for gcc is the use the unused attribute.
I think an idiomatic solution is : int unused ; unused ; Rene Rivera proposed this: namespace boost { namespace detail { inline void no_unused_variable_warning(void*) { } } } #define BOOST_NO_UNUSED_VARIABLE_WARNING(v) \ ::boost::detail::no_unused_variable_warning(&(v)) See namespace boost { namespace detail { inline void no_unused_variable_warning(void*) { } } } http://lists.boost.org/MailArchives/boost/msg54904.phpJonathan