Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / protocols / ace / INet / IOS_util.h
blobfbd8ac9a8bef0cfd19924a83ee80300fea64bef2
1 /**
2 * @file IOS_util.h
4 * @author Martin Corino <mcorino@remedy.nl>
5 */
7 #ifndef ACE_IOS_UTIL_H
8 #define ACE_IOS_UTIL_H
10 #include /**/ "ace/pre.h"
12 #include "ace/INet/INet_Export.h"
13 #include <iostream>
15 // ace_ios_init
17 // There is reported to be a bug in the Dinkumware
18 // implementation of iostreams where calling
19 // basic_ios::init() multiple times for the same
20 // basic_ios instance creates a memory leak as a result
21 // of the ios' locale being allocated more than
22 // once, each time overwriting the old pointer.
24 // This usually happens in multiple inheritance
25 // schemes involving a derived IOS class and a
26 // derived IO stream class (i, o or io).
28 // The fix for Dinkumware is to not call init() in the
29 // derived IOS class but call init() only for each
30 // stream object - in the istream, ostream or
31 // iostream constructor.
33 // Other stream implementations, however, require that
34 // init() is called in the derived IOS constructor.
35 // So we replace each call to init() with the
36 // ace_ios_init macro defined below.
39 #if !defined(ACE_IOS_INIT_FIX)
40 // Microsoft Visual Studio with Dinkumware STL (but not STLport)
41 # if defined(_MSC_VER) && (!defined(_STLP_MSVC) || defined(_STLP_NO_OWN_IOSTREAMS))
42 # define ACE_IOS_INIT_FIX 1
43 // QNX with Dinkumware but not GNU C++ Library
44 # elif defined(__QNX__) && !defined(__GLIBCPP__)
45 # define ACE_IOS_INIT_FIX 1
46 # endif
47 #endif
49 #if defined(ACE_IOS_INIT_FIX)
50 # define ace_ios_init(buf)
51 #else
52 # define ace_ios_init(buf) this->init(buf)
53 #endif
55 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
57 namespace ACE
59 namespace IOS
61 class ACE_INET_Export Null
63 public:
64 static std::ostream out_stream_;
65 static std::istream in_stream_;
70 ACE_END_VERSIONED_NAMESPACE_DECL
72 #include /**/ "ace/post.h"
73 #endif /* ACE_IOS_UTIL_H */