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