From 4ff64eea34088f4da11880d6f031fa9ad3f41423 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Wed, 19 Sep 2007 19:28:56 +0000 Subject: [PATCH] Add get_posix_category, get_system_category, to solve order-of-initialization issues [SVN r39394] --- include/boost/system/error_code.hpp | 11 +++++++---- src/error_code.cpp | 23 ++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 739d840..f0aa10a 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -162,12 +162,15 @@ namespace boost // predefined error categories -----------------------------------------// - BOOST_SYSTEM_DECL extern const error_category & posix_category; - BOOST_SYSTEM_DECL extern const error_category & system_category; + BOOST_SYSTEM_DECL const error_category & get_system_category(); + BOOST_SYSTEM_DECL const error_category & get_posix_category(); + static const error_category & system_category = get_system_category(); + static const error_category & posix_category = get_posix_category(); + // deprecated synonyms - BOOST_SYSTEM_DECL extern const error_category & errno_ecat; // posix_category - BOOST_SYSTEM_DECL extern const error_category & native_ecat; // system_category + static const error_category & errno_ecat = get_posix_category(); + static const error_category & native_ecat = get_system_category(); // class error_condition -----------------------------------------------// diff --git a/src/error_code.cpp b/src/error_code.cpp index 37b2dfa..cf7a1c2 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -214,8 +214,8 @@ namespace error_condition default_error_condition( int ev ) const; }; - const posix_error_category posix_category_const; - const system_error_category system_category_const; + const posix_error_category posix_category_const; + const system_error_category system_category_const; // posix_error_category implementation ---------------------------------// @@ -376,18 +376,15 @@ namespace boost namespace system { - BOOST_SYSTEM_DECL const error_category & posix_category - = posix_category_const; + BOOST_SYSTEM_DECL const error_category & get_system_category() + { + return system_category_const; + } - BOOST_SYSTEM_DECL const error_category & system_category - = system_category_const; - - // deprecated synonyms - BOOST_SYSTEM_DECL const error_category & errno_ecat - = posix_category_const; - - BOOST_SYSTEM_DECL const error_category & native_ecat - = system_category_const; + BOOST_SYSTEM_DECL const error_category & get_posix_category() + { + return posix_category_const; + } } // namespace system } // namespace boost