Boost logo

Boost Users :

Subject: Re: [Boost-users] Annoying compiler warnings in asio/error.hpp
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2010-07-13 09:47:32


please see my answer below.

> 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 think it is not the same as defining a global static variable. Global
static variable will have internal linkage and therefore be visible inside
the compilation unit where defined only. Between the compilation units these
variables will be different. IMO C++ like approach would be to introduce an
anonymous namespace in header files and define global variables there.
Defining static vars in the template class will result in a static variable
per class template instantiation. Which is not exactly the same, as intended


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at