Boost logo

Boost Users :

Subject: Re: [Boost-users] Annoying compiler warnings in asio/error.hpp
From: Emil Dotchevski (emil_at_[hidden])
Date: 2010-07-13 14:51:47


On Tue, Jul 13, 2010 at 2:39 AM, Hite, Christopher
<Christopher.Hite_at_[hidden]> wrote:
> /fs/tools/L1/boost_1_43_0/boost/asio/error.hpp: At global scope:
> /fs/tools/L1/boost_1_43_0/boost/asio/error.hpp:353: warning:
> ‘boost::asio::error::system_category’ defined but not used
> /fs/tools/L1/boost_1_43_0/boost/asio/error.hpp:355: warning:
> ‘boost::asio::error::netdb_category’ defined but not used
> /fs/tools/L1/boost_1_43_0/boost/asio/error.hpp:357: warning:
> ‘boost::asio::error::addrinfo_category’ defined but not used
>
> /fs/tools/L1/boost_1_43_0/boost/asio/error.hpp:359: warning:
> ‘boost::asio::error::misc_category’ defined but not used
> /fs/tools/L1/boost_1_43_0/boost/asio/error.hpp:361: warning:
> ‘boost::asio::error::ssl_category’ defined but not used
> /fs/tools/L1/boost_1_43_0/boost/system/error_code.hpp:208: warning:
> ‘boost::system::system_category’ defined but not used
>
> /fs/tools/L1/boost_1_43_0/boost/system/error_code.hpp:209: warning:
> ‘boost::system::generic_category’ defined but not used
>
> /fs/tools/L1/boost_1_43_0/boost/system/error_code.hpp:214: warning:
> ‘boost::system::posix_category’ defined but not used
>
> /fs/tools/L1/boost_1_43_0/boost/system/error_code.hpp:215: warning:
> ‘boost::system::errno_ecat’ defined but not used
> /fs/tools/L1/boost_1_43_0/boost/system/error_code.hpp:216: warning:
> ‘boost::system::native_ecat’ defined but not used
>
> Code defines static variables in header which is bad form.
>
> static const boost::system::error_category& system_category
>   = boost::asio::error::get_system_category();
>
> In gcc the warning could be disabled with  -Wno-unused-variable, but that
> disables valuable warnings.

It might be a good idea then to file a bug report with GCC requesting
that the two warnings be separated.

> If you really need to define global variables in a header only library, you
> can define static members of a template class.  It's a fancy trick (not sure
> if it has a name).  Perhaps there are portablity issues with it.

I'm sure there are plenty of creative ways to obfuscate your code.
Ideas, anyone? :)

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net