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