Browse Source

Replace CL_REQUIRE/CL_PROVIDE(cl_st_null) with portable code.

The order of initialization of non-local objects in different compilation units
is not specified in C++. Hence special care should be taken to avoid static
initialization order fiasco. CLN solved the problem with some evil (GCC
specific, and even GCC-version-specific) hack. Replace it with a technique
similar to one used in STL to initialize std::cout and friends.
master
Alexei Sheplyakov 16 years ago
parent
commit
d03e58e766
  1. 5
      include/cln/string.h
  2. 4
      src/base/string/cl_st_null.cc

5
include/cln/string.h

@ -124,10 +124,9 @@ inline cl_string::operator cl_heap_string* () const
}
inline cl_string::cl_string ()
{
extern const cl_string cl_null_string;
pointer = (cl_heap_string*) cl_null_string;
static const cl_string cl_null_st(NULL, 0);
pointer = (cl_heap_string*) cl_null_st;
}
CL_REQUIRE(cl_st_null)
// Hash code.
extern unsigned long hashcode (const cl_string& str);

4
src/base/string/cl_st_null.cc

@ -3,13 +3,12 @@
// General includes.
#include "cl_sysdep.h"
CL_PROVIDE(cl_st_null)
// Specification.
#include "cln/string.h"
namespace cln {
#warning "Please remove me"
extern const cl_string cl_null_string;
} // namespace cln
@ -22,4 +21,3 @@ const cl_string cl_null_string = cl_string(NULL,0);
} // namespace cln
CL_PROVIDE_END(cl_st_null)
Loading…
Cancel
Save