GL Studio API
version.h
Go to the documentation of this file.
1 /*! \file
2  \brief Used for matching version of libraries and headers.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2015 by The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 
41 #ifndef INCLUDED_GLS_VERSION_H
42 #define INCLUDED_GLS_VERSION_H
43 
44 /*
45  GL Studio version pattern
46  -----------------------------
47  X.Y.B00M
48  X = Major version
49  Y = Minor version
50  B = Build. Increment for maintenance releases. 1 is the lowest value for a released product, i.e. there is no released Build 0.
51  0 = Padding zeros.
52  M = Build Minor. Increment for in-house, pre-release builds and release candidates. This does not have to be zero when a product ships.
53 */
54 #include "gls_include.h"
55 
56 // For atoi
57 #include <stdlib.h>
58 
59 namespace disti
60 {
61 
62 #define GLS_VERSION_MAJOR 6
63 #define GLS_VERSION_MINOR 1
64 #define GLS_VERSION_BUILD 1001
65 #define GLS_BUILD_DATE "2017-10-31"
66 
67 // This does not necessarily stay up to date with the executable version
68 // The used license must be for this version or newer.
69 #define GLS_LICENSE_VERSION "5.0"
70 #define GLS_LICENSE_VERSION_INT 50
71 
72 
73 
74 #define GLS_STRINGIZE(x) #x
75 #define GLS_STRINGIZE_VALUE(x) GLS_STRINGIZE(x)
76 
77 // Build the GLS_VERSION string
78 #define GLS_VERSION_1(a,b) GLS_STRINGIZE(a.b)
79 #define GLS_VERSION GLS_VERSION_1(GLS_VERSION_MAJOR, GLS_VERSION_MINOR)
80 
81 // Build the GLS_BUILD_VERSION string
82 #define GLS_BUILD_VERSION GLS_STRINGIZE_VALUE(GLS_VERSION_BUILD)
83 
84 #if defined(WIN32)
85 
86 #if !defined(GLS_COMPILER_VERSION)
87 # if _MSC_VER < 1400
88 # pragma message("Warning (version.h): Unrecognized compiler version")
89 # define GLS_COMPILER_VERSION vcXX
90 # else
91 # if _MSC_VER < 1700
92 # pragma message("Warning (version.h): Unrecognized compiler version")
93 # define GLS_COMPILER_VERSION vcXX
94 # elif _MSC_VER < 1800
95 # define GLS_COMPILER_VERSION vc110
96 # elif _MSC_VER < 1900
97 # define GLS_COMPILER_VERSION vc120
98 # elif _MSC_VER < 1910
99 # define GLS_COMPILER_VERSION vc140
100 # elif _MSC_VER < 2000
101 # define GLS_COMPILER_VERSION vc141
102 # else
103 # pragma message("Warning (version.h): Unrecognized compiler version")
104 # define GLS_COMPILER_VERSION vcXX
105 # endif
106 # endif
107 #endif
108 
109 // 0x00FFFFFF - Reserved for _MSC_VER
110 // 0x01000000 - ML
111 // 0x02000000 - MT
112 // 0x04000000 - DLL
113 // 0x08000000 - DEBUG
114 #define GLS_CRT_VERSION_INT_MD 0x06000000 // MT + DLL
115 #define GLS_CRT_VERSION_INT_MT 0x02000000 // MT
116 #define GLS_CRT_VERSION_INT_ML 0x01000000 // ML
117 #define GLS_CRT_VERSION_INT_MDD 0x0E000000 // DEBUG + MT + DLL
118 #define GLS_CRT_VERSION_INT_MTD 0x0A000000 // DEBUG + MT
119 #define GLS_CRT_VERSION_INT_MLD 0x09000000 // DEBUG + ML
120 
121 #define GLS_CRT_VERSION_INT_MD_64 0x16000000 // MT + DLL
122 #define GLS_CRT_VERSION_INT_MT_64 0x12000000 // MT
123 #define GLS_CRT_VERSION_INT_ML_64 0x11000000 // ML
124 #define GLS_CRT_VERSION_INT_MDD_64 0x1E000000 // DEBUG + MT + DLL
125 #define GLS_CRT_VERSION_INT_MTD_64 0x1A000000 // DEBUG + MT
126 #define GLS_CRT_VERSION_INT_MLD_64 0x19000000 // DEBUG + ML
127 
128 #if !defined(GLS_CRT_VERSION)
129 # if defined(_DEBUG)
130 # if defined(_MT)
131 # if defined(_DLL)
132 # if defined(_WIN64)
133 # define GLS_CRT_VERSION _64mdd
134 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MDD_64
135 # else
136 # define GLS_CRT_VERSION mdd
137 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MDD
138 # endif
139 # else
140 # if defined(_WIN64)
141 # define GLS_CRT_VERSION _64mtd
142 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MTD_64
143 # else
144 # define GLS_CRT_VERSION mtd
145 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MTD
146 # endif
147 # endif
148 # else
149 # if defined(_WIN64)
150 # define GLS_CRT_VERSION _64mld
151 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MLD_64
152 # else
153 # define GLS_CRT_VERSION mld
154 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MLD
155 # endif
156 # endif
157 # else
158 # if defined(_MT)
159 # if defined(_DLL)
160 # if defined(_WIN64)
161 # define GLS_CRT_VERSION _64md
162 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MD_64
163 # else
164 # define GLS_CRT_VERSION md
165 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MD
166 # endif
167 # else
168 # if defined(_WIN64)
169 # define GLS_CRT_VERSION _64mt
170 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MT_64
171 # else
172 # define GLS_CRT_VERSION mt
173 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MT
174 # endif
175 # endif
176 # else
177 # if defined(_WIN64)
178 # define GLS_CRT_VERSION _64ml
179 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_ML_64
180 # else
181 # define GLS_CRT_VERSION ml
182 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_ML
183 # endif
184 # endif
185 # endif
186 #endif
187 
188 // Build the GLS_CHECK_VERSION_ID function name
189 #define GLS_CHECK_VERSION_ID_2( a, b, c, d, e ) GLS_VERSION_##a##_##b##_##c##_##d##_##e // Complete check
190 #define GLS_CHECK_VERSION_ID_1( v1, v2, v3, c1, c2 ) GLS_CHECK_VERSION_ID_2( v1, v2, v3, c1, c2 )
191 #define GLS_CHECK_VERSION_ID GLS_CHECK_VERSION_ID_1( GLS_VERSION_MAJOR, GLS_VERSION_MINOR, GLS_VERSION_BUILD, GLS_COMPILER_VERSION, GLS_CRT_VERSION )
192 
193 #else // UNIX
194 
195 // Build the GLS_CHECK_VERSION_ID function name
196 #define GLS_CHECK_VERSION_ID_2( a, b, c ) GLS_VERSION_##a##_##b##_##c##_LIBRARY
197 #define GLS_CHECK_VERSION_ID_1( v1, v2, v3 ) GLS_CHECK_VERSION_ID_2( v1, v2, v3 )
198 #define GLS_CHECK_VERSION_ID GLS_CHECK_VERSION_ID_1( GLS_VERSION_MAJOR, GLS_VERSION_MINOR, GLS_VERSION_BUILD )
199 
200 #endif
201 
202 
203 GLS_EXPORT void GLS_CHECK_VERSION_ID();
204 
205 /** This is a type which shall remain consistant. If an item must
206  * be added, it shall be added at the end of the structure to avoid
207  * compatibility issues.
208  * This object is used to check dynamically loaded code with the container
209  * performing the load.
210  * This must be inline to work properly.
211  */
213 {
214 public:
215  int _glsMajor;
216  int _glsMinor;
217  int _glsBuild;
218  int _compilerVersion;
219 
220  inline GlsBuiltVersionInfo2(
221  int glsMajor = GLS_VERSION_MAJOR,
222  int glsMinor = GLS_VERSION_MINOR,
223  int glsBuild = GLS_VERSION_BUILD,
224 #if defined(_MSC_VER)
225  int compilerVersion = _MSC_VER + GLS_CRT_VERSION_INT ) // Complete check
226 #elif defined(__GNUC__)
227  int compilerVersion = __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
228 #else
229  int compilerVersion = 0)
230 #endif
231  {
232  _glsMajor = glsMajor;
233  _glsMinor = glsMinor;
234  _glsBuild = glsBuild;
235  _compilerVersion = compilerVersion;
236  }
237 };
238 
240 
241 // Returns true if the version info matches exactly
242 // (They reference the same dll / so)
243 inline bool GlsBuiltVersionsMatchExactly(const GlsBuiltVersionInfo& a, const GlsBuiltVersionInfo& b)
244 {
245  return a._glsMajor == b._glsMajor &&
246  a._glsMinor == b._glsMinor &&
247  a._glsBuild == b._glsBuild &&
248  a._compilerVersion == b._compilerVersion;
249 }
250 
251 // Returns true if the versions are binary compatible
252 // (May be different dll / so, but they are link compatible)
253 inline bool GlsBuiltVersionsAreBinaryCompatible(const GlsBuiltVersionInfo& a, const GlsBuiltVersionInfo& b)
254 {
255  bool compiler_compatible = (a._compilerVersion == b._compilerVersion);
256 
257 #if defined(__GNUC__)
258 
259  if (!compiler_compatible)
260  {
261  if (a._compilerVersion >= 30400 && a._compilerVersion < 30500 &&
262  b._compilerVersion >= 30400 && b._compilerVersion < 30500)
263  {
264  // GCC 3.4.0 - 3.4.X: GCC 3.4.2 compatible
265  // The C runtime library changed with 3.4.0
266  compiler_compatible = true;
267  }
268  else if (a._compilerVersion >= 40000 && a._compilerVersion < 40200 &&
269  b._compilerVersion >= 40000 && b._compilerVersion < 40200)
270  {
271  // Assume GCC 4.0.0 compatible
272  compiler_compatible = true;
273  }
274  else if (a._compilerVersion >= 40200 && a._compilerVersion < 40400 &&
275  b._compilerVersion >= 40200 && b._compilerVersion < 40400)
276  {
277  // Assume GCC 4.2.0 compatible
278  compiler_compatible = true;
279  }
280  else if (a._compilerVersion >= 40400 && a._compilerVersion < 40600 &&
281  b._compilerVersion >= 40400 && b._compilerVersion < 40600)
282  {
283  // Assume GCC 4.4.0 compatible
284  compiler_compatible = true;
285  }
286  else if (a._compilerVersion >= 40600 && a._compilerVersion < 40800 &&
287  b._compilerVersion >= 40600 && b._compilerVersion < 40800)
288  {
289  // Assume GCC 4.6.0 compatible
290  compiler_compatible = true;
291  }
292  }
293 
294 #endif
295 
296  return (compiler_compatible &&
297  a._glsMajor == b._glsMajor &&
298  a._glsMinor == b._glsMinor &&
299  a._glsBuild/1000 == b._glsBuild/1000 );
300 }
301 
302 } // namespace disti
303 
304 #endif
A file for all GL Studio files to include.
Definition: version.h:212
Definition: bmpimage.h:46