xapian-core  1.4.19
version_h.cc
Go to the documentation of this file.
1 
6 #include <config.h>
7 const char * dummy[] = {
8 "/** @file",
9 " * @brief Define preprocessor symbols for the library version",
10 " */",
11 "// Copyright (C) 2002,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2015,2016,2017,2018,2020 Olly Betts",
12 "//",
13 "// This program is free software; you can redistribute it and/or",
14 "// modify it under the terms of the GNU General Public License as",
15 "// published by the Free Software Foundation; either version 2 of the",
16 "// License, or (at your option) any later version.",
17 "//",
18 "// This program is distributed in the hope that it will be useful,",
19 "// but WITHOUT ANY WARRANTY; without even the implied warranty of",
20 "// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
21 "// GNU General Public License for more details.",
22 "//",
23 "// You should have received a copy of the GNU General Public License",
24 "// along with this program; if not, write to the Free Software",
25 "// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA",
26 "",
27 "#ifndef XAPIAN_INCLUDED_VERSION_H",
28 "#define XAPIAN_INCLUDED_VERSION_H",
29 "",
30 // Disabled for now, since str.h is used by omega, and includes visibility.h
31 // which includes version.h. (FIXME)
32 //"#if !defined XAPIAN_INCLUDED_XAPIAN_H && !defined XAPIAN_LIB_BUILD",
33 //"# error @@Never use <xapian/version.h> directly; include <xapian.h> instead.@@",
34 //"#endif",
35 //"",
36 #ifdef __GNUC__
37 // When building the library with GCC, generate preprocessor code to check that
38 // any version of GCC used to build applications has a matching C++ ABI. This
39 // means that users get a nice explanatory error message rather than a
40 // confusing link failure (or worse a program which builds but crashes).
41 // Another benefit is that the check happens near the start of compilation of
42 // the first source file which uses Xapian in the user's application, rather
43 // than during the first attempt to link with Xapian.
44 //
45 // We also check that the setting of _GLIBCXX_DEBUG matches since that
46 // introduces ABI-like incompatibilities.
47 //
48 // After preprocessing with "g++ -E" or similar (which will expand macros,
49 // strip comments such as this block, etc) we remove lines starting with a
50 // '#', remove blank lines, and collapse multiple spaces. And we strip out
51 // double quotes, then replace '@@' with '"', and drop ',' at the end of a
52 // line (the purpose of the ',' is to prevent certain preprocessors from
53 // concatenating literal strings).
54 //
55 // So for lines we want in the output, we quote parts of the line which we
56 // don't want substituting, and use @@ where we really want " in the output.
57 #if defined __clang__
58 # define BUILD_COMPILER "clang++ " __clang_version__
59 #elif defined __INTEL_COMPILER
60 # define BUILD_COMPILER "icc " J(__INTEL_COMPILER)
61 # define J(A) #A
62 #elif defined __GNUC_PATCHLEVEL__
63 # define BUILD_COMPILER "g++ " V(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
64 # define V(A,B,C) J(A,B,C)
65 # define J(A,B,C) #A"."#B"."#C
66 #else
67 # define BUILD_COMPILER "g++ " V(__GNUC__, __GNUC_MINOR__)
68 # define V(A,B) J(A,B)
69 # define J(A,B) #A"."#B
70 #endif
71 "#ifdef __GNUC__",
72 "#if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ == 0)",
73 "#error Xapian no longer supports GCC < 3.1",
74 "#else",
75 #ifndef __GXX_ABI_VERSION
76 #error GCC does not have __GXX_ABI_VERSION defined
77 #endif
78 // GCC 3.1 reports ABI version 100 (same as 3.0), but this should actually have
79 // been 101! But we reject 3.0 above, so this doesn't actually matter.
80 "#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION != ", __GXX_ABI_VERSION,
81 #if __GXX_ABI_VERSION >= 1002
82 // ABI versions 2 and up are compatible aside from obscure corner cases, so
83 // issue a warning, but don't refuse to compile as there's a good chance that
84 // things will actually work.
85 "#if defined __GXX_ABI_VERSION && __GXX_ABI_VERSION >= 1002",
86 "#warning The C++ ABI version of compiler you are using does not exactly match",
87 "#warning that of the compiler used to build the library. If linking fails",
88 "#warning due to missing symbols, this is probably the reason why.",
89 "#warning The Xapian library was built with ", BUILD_COMPILER
90 "#else",
91 #endif
92 "#error The C++ ABI version of compiler you are using does not match",
93 "#error that of the compiler used to build the library. The versions",
94 "#error must match or your program will not work correctly.",
95 "#error The Xapian library was built with ", BUILD_COMPILER
96 #if __GXX_ABI_VERSION >= 1002
97 "#endif",
98 #endif
99 "#endif",
100 "",
101 // _GLIBCXX_DEBUG is supported by GCC 3.4 and later so we only need to check
102 // it for those versions.
103 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4
104 #ifdef _GLIBCXX_DEBUG
105 "#ifndef _GLIBCXX_DEBUG",
106 "#error This library was compiled with _GLIBCXX_DEBUG defined, but you",
107 "#error have not specified this flag. The settings must match or your",
108 "#error program will not work correctly.",
109 "#endif",
110 #else
111 "#ifdef _GLIBCXX_DEBUG",
112 "#error You are compiling with _GLIBCXX_DEBUG defined, but the library",
113 "#error was not compiled with this flag. The settings must match or your",
114 "#error program will not work correctly.",
115 "#endif",
116 #endif
117 #endif
118 "#endif",
119 "#endif",
120 "",
121 #elif defined _MSC_VER
122 // When building the library with MSVC, generate preprocessor code to check
123 // that the same setting of _DEBUG is used for building applications as was
124 // used for building the library.
125 "#ifdef _MSC_VER",
126 #ifdef _DEBUG
127 "#ifndef _DEBUG",
128 "#error This library was compiled with _DEBUG defined, but you",
129 "#error have not specified this flag. The settings must match or your",
130 "#error program will not work correctly.",
131 "#endif",
132 #else
133 "#ifdef _DEBUG",
134 "#error You are compiling with _DEBUG defined, but the library",
135 "#error was not compiled with this flag. The settings must match or your",
136 "#error program will not work correctly.",
137 "#endif",
138 #endif
139 "#endif",
140 "",
141 #endif
142 #ifdef XAPIAN_ENABLE_VISIBILITY
143 "/// The library was compiled with GCC's -fvisibility=hidden option.",
144 "#define XAPIAN_ENABLE_VISIBILITY",
145 "",
146 #endif
147 "/// The version of Xapian as a C string literal.",
148 "#define XAPIAN_VERSION ", STRING_VERSION,
149 "",
150 "/** The major component of the Xapian version.",
151 " * E.g. for Xapian 1.0.14 this would be: 1",
152 " */",
153 "#define XAPIAN_MAJOR_VERSION ", MAJOR_VERSION,
154 "",
155 "/** The minor component of the Xapian version.",
156 " * E.g. for Xapian 1.0.14 this would be: 0",
157 " */",
158 "#define XAPIAN_MINOR_VERSION ", MINOR_VERSION,
159 "",
160 "/** The revision component of the Xapian version.",
161 " * E.g. for Xapian 1.0.14 this would be: 14",
162 " */",
163 "#define XAPIAN_REVISION ", REVISION,
164 "",
165 "/// Base (signed) type for Xapian::docid and related types.",
166 "#define XAPIAN_DOCID_BASE_TYPE ", XAPIAN_DOCID_BASE_TYPE,
167 "",
168 "/// Base (signed) type for Xapian::termcount and related types.",
169 "#define XAPIAN_TERMCOUNT_BASE_TYPE ", XAPIAN_TERMCOUNT_BASE_TYPE,
170 "",
171 "/// Base (signed) type for Xapian::termpos.",
172 "#define XAPIAN_TERMPOS_BASE_TYPE ", XAPIAN_TERMPOS_BASE_TYPE,
173 "",
174 "/// Type for returning total document length.",
175 "#define XAPIAN_TOTALLENGTH_TYPE ", XAPIAN_REVISION_TYPE,
176 "",
177 "/// Underlying type for Xapian::rev.",
178 "#define XAPIAN_REVISION_TYPE ", XAPIAN_REVISION_TYPE,
179 "",
180 "/// XAPIAN_HAS_CHERT_BACKEND Defined if the chert backend is enabled.",
181 #ifdef XAPIAN_HAS_CHERT_BACKEND
182 "#define XAPIAN_HAS_CHERT_BACKEND 1",
183 #else
184 "/* #undef XAPIAN_HAS_CHERT_BACKEND */",
185 #endif
186 "",
187 "/// XAPIAN_HAS_GLASS_BACKEND Defined if the glass backend is enabled.",
188 #ifdef XAPIAN_HAS_GLASS_BACKEND
189 "#define XAPIAN_HAS_GLASS_BACKEND 1",
190 #else
191 "/* #undef XAPIAN_HAS_GLASS_BACKEND */",
192 #endif
193 "",
194 "/// XAPIAN_HAS_INMEMORY_BACKEND Defined if the inmemory backend is enabled.",
195 #ifdef XAPIAN_HAS_INMEMORY_BACKEND
196 "#define XAPIAN_HAS_INMEMORY_BACKEND 1",
197 #else
198 "/* #undef XAPIAN_HAS_INMEMORY_BACKEND */",
199 #endif
200 "",
201 "/// XAPIAN_HAS_REMOTE_BACKEND Defined if the remote backend is enabled.",
202 #ifdef XAPIAN_HAS_REMOTE_BACKEND
203 "#define XAPIAN_HAS_REMOTE_BACKEND 1",
204 #else
205 "/* #undef XAPIAN_HAS_REMOTE_BACKEND */",
206 #endif
207 "",
208 "/// XAPIAN_AT_LEAST(A,B,C) checks for xapian-core >= A.B.C - use like so:",
209 "///",
210 "/// @code",
211 "/// #if XAPIAN_AT_LEAST(1,4,2)",
212 "/// /* Code needing features needing Xapian >= 1.4.2. */",
213 "/// #endif",
214 "/// @endcode",
215 "///",
216 "/// Added in Xapian 1.4.2.",
217 "#define XAPIAN_AT_LEAST(A,B,C) \\",
218 " (XAPIAN_MAJOR_VERSION > (A) || \\",
219 " (XAPIAN_MAJOR_VERSION == (A) && \\",
220 " (XAPIAN_MINOR_VERSION > (B) || \\",
221 " (XAPIAN_MINOR_VERSION == (B) && XAPIAN_REVISION >= (C)))))",
222 "",
223 "/// We support move semantics when we're confident the compiler supports it.",
224 "///",
225 "/// C++11 move semantics are very useful in threaded code that wants to",
226 "/// hand-off Xapian objects to worker threads, but in this case it's very",
227 "/// unhelpful for availability of these semantics to vary by compiler as it",
228 "/// quietly leads to a build with non-threadsafe behaviour.",
229 "///",
230 "/// User code can #define XAPIAN_MOVE_SEMANTICS to force this on, and will",
231 "/// then get a compilation failure if the compiler lacks suitable support.",
232 "#ifndef XAPIAN_MOVE_SEMANTICS",
233 "# if __cplusplus >= 201103L || \\",
234 " (defined _MSC_VER && _MSC_VER >= 1900) || \\",
235 " defined XAPIAN_LIB_BUILD",
236 "# define XAPIAN_MOVE_SEMANTICS",
237 "# endif",
238 "#endif",
239 "",
240 "#endif /* XAPIAN_INCLUDED_VERSION_H */"
241 };
#define XAPIAN_TERMPOS_BASE_TYPE
Base (signed) type for Xapian::termpos.
Definition: version.h:77
const char * dummy[]
Definition: version_h.cc:7
#define XAPIAN_REVISION_TYPE
Underlying type for Xapian::rev.
Definition: version.h:83
#define XAPIAN_DOCID_BASE_TYPE
Base (signed) type for Xapian::docid and related types.
Definition: version.h:71
unsigned REVISION(const uint8_t *b)
Definition: chert_table.h:150
#define XAPIAN_TERMCOUNT_BASE_TYPE
Base (signed) type for Xapian::termcount and related types.
Definition: version.h:74