GL Studio C++ Runtime API
gls_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) 2018 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 7
63 #define GLS_VERSION_MINOR 0
64 #define GLS_VERSION_BUILD 0000
65 
66 #define GLS_STRINGIZE(x) #x
67 #define GLS_STRINGIZE_VALUE(x) GLS_STRINGIZE(x)
68 
69 // Build the GLS_VERSION string
70 #define GLS_VERSION_1(a,b) GLS_STRINGIZE(a.b)
71 #define GLS_VERSION GLS_VERSION_1(GLS_VERSION_MAJOR, GLS_VERSION_MINOR)
72 // Allows customers to upgrade within major versions without requiring an updated license.
73 #define GLS_LICENSE_VERSION GLS_VERSION_1(GLS_VERSION_MAJOR, 0)
74 
75 // Build the GLS_BUILD_VERSION string
76 #define GLS_BUILD_VERSION GLS_STRINGIZE_VALUE(GLS_VERSION_BUILD)
77 
78 #if defined(WIN32)
79 
80 #if !defined(GLS_COMPILER_VERSION)
81 # if _MSC_VER < 1400
82 # pragma message("Warning (gls_version.h): Unrecognized compiler version")
83 # define GLS_COMPILER_VERSION vcXX
84 # else
85 # if _MSC_VER < 1700
86 # pragma message("Warning (gls_version.h): Unrecognized compiler version")
87 # define GLS_COMPILER_VERSION vcXX
88 # elif _MSC_VER < 1800
89 # define GLS_COMPILER_VERSION vc110
90 # elif _MSC_VER < 1900
91 # define GLS_COMPILER_VERSION vc120
92 # elif _MSC_VER < 1910
93 # define GLS_COMPILER_VERSION vc140
94 # elif _MSC_VER < 2000
95 # define GLS_COMPILER_VERSION vc141
96 # else
97 # pragma message("Warning (gls_version.h): Unrecognized compiler version")
98 # define GLS_COMPILER_VERSION vcXX
99 # endif
100 # endif
101 #endif
102 
103 // 0x00FFFFFF - Reserved for _MSC_VER
104 // 0x01000000 - ML
105 // 0x02000000 - MT
106 // 0x04000000 - DLL
107 // 0x08000000 - DEBUG
108 #define GLS_CRT_VERSION_INT_MD 0x06000000 // MT + DLL
109 #define GLS_CRT_VERSION_INT_MT 0x02000000 // MT
110 #define GLS_CRT_VERSION_INT_ML 0x01000000 // ML
111 #define GLS_CRT_VERSION_INT_MDD 0x0E000000 // DEBUG + MT + DLL
112 #define GLS_CRT_VERSION_INT_MTD 0x0A000000 // DEBUG + MT
113 #define GLS_CRT_VERSION_INT_MLD 0x09000000 // DEBUG + ML
114 
115 #define GLS_CRT_VERSION_INT_MD_64 0x16000000 // MT + DLL
116 #define GLS_CRT_VERSION_INT_MT_64 0x12000000 // MT
117 #define GLS_CRT_VERSION_INT_ML_64 0x11000000 // ML
118 #define GLS_CRT_VERSION_INT_MDD_64 0x1E000000 // DEBUG + MT + DLL
119 #define GLS_CRT_VERSION_INT_MTD_64 0x1A000000 // DEBUG + MT
120 #define GLS_CRT_VERSION_INT_MLD_64 0x19000000 // DEBUG + ML
121 
122 #if !defined(GLS_CRT_VERSION)
123 # if defined(_DEBUG)
124 # if defined(_MT)
125 # if defined(_DLL)
126 # if defined(_WIN64)
127 # define GLS_CRT_VERSION _64mdd
128 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MDD_64
129 # else
130 # define GLS_CRT_VERSION mdd
131 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MDD
132 # endif
133 # else
134 # if defined(_WIN64)
135 # define GLS_CRT_VERSION _64mtd
136 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MTD_64
137 # else
138 # define GLS_CRT_VERSION mtd
139 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MTD
140 # endif
141 # endif
142 # else
143 # if defined(_WIN64)
144 # define GLS_CRT_VERSION _64mld
145 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MLD_64
146 # else
147 # define GLS_CRT_VERSION mld
148 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MLD
149 # endif
150 # endif
151 # else
152 # if defined(_MT)
153 # if defined(_DLL)
154 # if defined(_WIN64)
155 # define GLS_CRT_VERSION _64md
156 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MD_64
157 # else
158 # define GLS_CRT_VERSION md
159 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MD
160 # endif
161 # else
162 # if defined(_WIN64)
163 # define GLS_CRT_VERSION _64mt
164 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MT_64
165 # else
166 # define GLS_CRT_VERSION mt
167 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_MT
168 # endif
169 # endif
170 # else
171 # if defined(_WIN64)
172 # define GLS_CRT_VERSION _64ml
173 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_ML_64
174 # else
175 # define GLS_CRT_VERSION ml
176 # define GLS_CRT_VERSION_INT GLS_CRT_VERSION_INT_ML
177 # endif
178 # endif
179 # endif
180 #endif
181 
182 // Build the GLS_CHECK_VERSION_ID function name
183 #define GLS_CHECK_VERSION_ID_2( a, b, c, d, e ) GLS_VERSION_##a##_##b##_##c##_##d##_##e // Complete check
184 #define GLS_CHECK_VERSION_ID_1( v1, v2, v3, c1, c2 ) GLS_CHECK_VERSION_ID_2( v1, v2, v3, c1, c2 )
185 #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 )
186 
187 #else // UNIX
188 
189 // Build the GLS_CHECK_VERSION_ID function name
190 #define GLS_CHECK_VERSION_ID_2( a, b, c ) GLS_VERSION_##a##_##b##_##c##_LIBRARY
191 #define GLS_CHECK_VERSION_ID_1( v1, v2, v3 ) GLS_CHECK_VERSION_ID_2( v1, v2, v3 )
192 #define GLS_CHECK_VERSION_ID GLS_CHECK_VERSION_ID_1( GLS_VERSION_MAJOR, GLS_VERSION_MINOR, GLS_VERSION_BUILD )
193 
194 #endif
195 
196 
197 GLS_EXPORT void GLS_CHECK_VERSION_ID();
198 
199 /** This is a type which shall remain consistant. If an item must
200  * be added, it shall be added at the end of the structure to avoid
201  * compatibility issues.
202  * This object is used to check dynamically loaded code with the container
203  * performing the load.
204  * This must be inline to work properly.
205  */
207 {
208 public:
209  int _glsMajor;
210  int _glsMinor;
211  int _glsBuild;
212  int _compilerVersion;
213 
214  inline GlsBuiltVersionInfo2(
215  int glsMajor = GLS_VERSION_MAJOR,
216  int glsMinor = GLS_VERSION_MINOR,
217  int glsBuild = GLS_VERSION_BUILD,
218 #if defined(_MSC_VER)
219  int compilerVersion = _MSC_VER + GLS_CRT_VERSION_INT ) // Complete check
220 #elif defined(__GNUC__)
221  int compilerVersion = __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
222 #else
223  int compilerVersion = 0)
224 #endif
225  {
226  _glsMajor = glsMajor;
227  _glsMinor = glsMinor;
228  _glsBuild = glsBuild;
229  _compilerVersion = compilerVersion;
230  }
231 };
232 
234 
235 // Returns true if the version info matches exactly
236 // (They reference the same dll / so)
237 inline bool GlsBuiltVersionsMatchExactly(const GlsBuiltVersionInfo& a, const GlsBuiltVersionInfo& b)
238 {
239  return a._glsMajor == b._glsMajor &&
240  a._glsMinor == b._glsMinor &&
241  a._glsBuild == b._glsBuild &&
242  a._compilerVersion == b._compilerVersion;
243 }
244 
245 // Returns true if the versions are binary compatible
246 // (May be different dll / so, but they are link compatible)
247 inline bool GlsBuiltVersionsAreBinaryCompatible(const GlsBuiltVersionInfo& a, const GlsBuiltVersionInfo& b)
248 {
249  bool compiler_compatible = (a._compilerVersion == b._compilerVersion);
250 
251 #if defined(__GNUC__)
252 
253  if (!compiler_compatible)
254  {
255  if (a._compilerVersion >= 30400 && b._compilerVersion >= 30400 )
256  {
257  // GCC 3.4.0 or newer
258  // The C runtime library changed with 3.4.0
259  compiler_compatible = true;
260  }
261  }
262 
263 #endif
264 
265  // If this does not match, we fallback to RSO interface
266  return (compiler_compatible &&
267  a._glsMajor == b._glsMajor &&
268  a._glsMinor == b._glsMinor &&
269  a._glsBuild/1000 == b._glsBuild/1000 );
270 }
271 
272 } // namespace disti
273 
274 #endif
A file for all GL Studio files to include.
Definition: gls_version.h:206
Definition: bmpimage.h:46