]> Dogcows Code - chaz/yoink/blob - src/stlplus/portability/portability_fixes.hpp
testing new non-autotools build system
[chaz/yoink] / src / stlplus / portability / portability_fixes.hpp
1 #ifndef STLPLUS_PORTABILITY_FIXES
2 #define STLPLUS_PORTABILITY_FIXES
3 ////////////////////////////////////////////////////////////////////////////////
4
5 // Author: Andy Rushton
6 // Copyright: (c) Southampton University 1999-2004
7 // (c) Andy Rushton 2004-2009
8 // License: BSD License, see ../docs/license.html
9
10 // Contains work arounds for OS or Compiler specific problems to try to make
11 // them look more alike
12
13 // It is strongly recommended that this header be included as the first
14 // #include in every source file
15
16 ////////////////////////////////////////////////////////////////////////////////
17
18 ////////////////////////////////////////////////////////////////////////////////
19 // Problem with MicroSoft defining two different macros to identify Windows
20 ////////////////////////////////////////////////////////////////////////////////
21
22 #if defined(_WIN32) || defined(_WIN32_WCE)
23 #define MSWINDOWS
24 #endif
25
26 ////////////////////////////////////////////////////////////////////////////////
27 // Problems with unnecessary or unfixable compiler warnings
28 ////////////////////////////////////////////////////////////////////////////////
29
30 #ifdef _MSC_VER
31 // Microsoft Visual Studio
32 // shut up the following irritating warnings
33 // 4786 - VC6, identifier string exceeded maximum allowable length and was truncated (only affects debugger)
34 // 4305 - VC6, identifier type was converted to a smaller type
35 // 4503 - VC6, decorated name was longer than the maximum the compiler allows (only affects debugger)
36 // 4309 - VC6, type conversion operation caused a constant to exceeded the space allocated for it
37 // 4290 - VC6, C++ exception specification ignored
38 // 4800 - VC6, forcing value to bool 'true' or 'false' (performance warning)
39 // 4675 - VC7.1, "change" in function overload resolution _might_ have altered program
40 // 4996 - VC8, 'xxxx' was declared deprecated
41 #pragma warning(disable: 4786 4305 4503 4309 4290 4800 4675 4996)
42 #endif
43
44 #ifdef __BORLANDC__
45 // Borland
46 // Shut up the following irritating warnings
47 // 8026 - Functions with exception specifications are not expanded inline
48 // 8027 - Functions with xxx are not expanded inline
49 #pragma warn -8026
50 #pragma warn -8027
51 #endif
52
53 ////////////////////////////////////////////////////////////////////////////////
54 // Problems with redefinition of min/max in various different versions of library headers
55 ////////////////////////////////////////////////////////////////////////////////
56
57 // The Windows headers define macros called max/min which conflict with the templates std::max and std::min.
58 // So, to avoid conflicts, MS removed the std::max/min rather than fixing the problem!
59 // From Visual Studio .NET (SV7, compiler version 13.00) the STL templates have been added correctly.
60 // For MFC compatibility, only undef min and max in non-MFC programs - some bits of MFC
61 // use macro min/max in headers.
62
63 // I've created extra template function definitions minimum/maximum that avoid all the problems above
64
65 namespace stlplus
66 {
67 template<typename T> const T& maximum(const T& l, const T& r) {return l > r ? l : r;}
68 template<typename T> const T& minimum(const T& l, const T& r) {return l < r ? l : r;}
69 }
70
71 ////////////////////////////////////////////////////////////////////////////////
72 // Problems with differences between namespaces
73 ////////////////////////////////////////////////////////////////////////////////
74
75 // Note: not sure of the relevance of this - maybe deprecated?
76 // problem in gcc pre-v3 where the sub-namespaces in std aren't present
77 // this mean that the statement "using namespace std::rel_ops" created an error because the namespace didn't exist
78
79 // I've done a fix here that creates an empty namespace for this case, but I
80 // do *not* try to move the contents of std::rel_ops into namespace std
81 // This fix only works if you use "using namespace std::rel_ops" to bring in the template relational operators (e.g. != defined i.t.o. ==)
82
83 #ifdef __GNUC__
84 namespace std
85 {
86 namespace rel_ops
87 {
88 }
89 }
90 #endif
91
92 ////////////////////////////////////////////////////////////////////////////////
93 // problems with missing functions
94 ////////////////////////////////////////////////////////////////////////////////
95
96 #ifdef MSWINDOWS
97 unsigned sleep(unsigned seconds);
98 #else
99 #include <unistd.h>
100 #endif
101
102 ////////////////////////////////////////////////////////////////////////////////
103 // Function for establishing endian-ness
104 ////////////////////////////////////////////////////////////////////////////////
105 // Different machine architectures store data using different byte orders.
106 // This is referred to as Big- and Little-Endian Byte Ordering.
107 //
108 // The issue is: where does a pointer to an integer type actually point?
109 //
110 // In both conventions, the address points to the left of the word but:
111 // Big-Endian - The most significant byte is on the left end of a word
112 // Little-Endian - The least significant byte is on the left end of a word
113 //
114 // Bytes are addressed left to right, so in big-endian order byte 0 is the
115 // msB, whereas in little-endian order byte 0 is the lsB. For example,
116 // Intel-based machines store data in little-endian byte order so byte 0 is
117 // the lsB.
118 //
119 // This function establishes byte order at run-time
120
121 namespace stlplus
122 {
123 bool little_endian(void);
124 }
125
126 ////////////////////////////////////////////////////////////////////////////////
127 #endif
This page took 0.034699 seconds and 4 git commands to generate.