Boost logo

Boost Users :

Subject: [Boost-users] Annoying compiler warnings in asio/error.hpp
From: Hite, Christopher (Christopher.Hite_at_[hidden])
Date: 2010-07-13 05:39:30


/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.

Are these variables really needed? They theoretically create a word per
compilation scope.

A cleaner alternative would be to just call the function where needed.

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.

Chris



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