|
Boost Users : |
Subject: Re: [Boost-users] Annoying compiler warnings in asio/error.hpp
From: Hite, Christopher (Christopher.Hite_at_[hidden])
Date: 2010-07-16 10:08:16
> What you describe here is the opposite of what is stated in the lib.
> As far as I understand the author's intention by declaring a global
variable
> static: introdcution of an own copy of this var in each compilation
unit.
The author just wanted a constant which you ask for a name/message.
Actually the variable ssl_category is not used anywhere. They call
get_ssl_category() which has a static function variable.
That is another good trick to create a global variable which exists in
all compilation scopes. Code like this in a header will generate on
instance of X shared between compilation scopes.
Class X{}
inline X& getOneAndOnlyX(){
static X x;
return x;
}
Anyways I'm guessing you could just kick ssl_category. I can't find
these constants documented anywhere in the reference. ssl_category
isn't used in tests. Some of the others are used, but since they are
the same as what the inline functions would return.
Perhaps the author was afraid in a multi threaded environment functions
like getOneAndOnlyX() aren't safe. I know gcc by default generates
atomic ops so only one X is constructed. Perhaps the idea was to ensure
all these things were created before main() gets a chance to start
threads.
I don't have a checkout. Maybe someone could svn blame the file and
find out who defined these things and ask them what they were thinking.
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