2 * @brief Template used by configure to generate xapian/version.h
4 * (For portability, files run through $CXXCPP must have extension .c .cc or .C)
7 const char * dummy
[] = {
9 " * @brief Define preprocessor symbols for the library version",
11 "// Copyright (C) 2002,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2015,2016,2017,2018,2020 Olly Betts",
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.",
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.",
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",
27 "#ifndef XAPIAN_INCLUDED_VERSION_H",
28 "#define XAPIAN_INCLUDED_VERSION_H",
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.@@",
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.
45 // We also check that the setting of _GLIBCXX_DEBUG matches since that
46 // introduces ABI-like incompatibilities.
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).
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.
58 # define BUILD_COMPILER "clang++ " __clang_version__
59 #elif defined __INTEL_COMPILER
60 # define BUILD_COMPILER "icc " J(__INTEL_COMPILER)
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
67 # define BUILD_COMPILER "g++ " V(__GNUC__, __GNUC_MINOR__)
68 # define V(A,B) J(A,B)
69 # define J(A,B) #A"."#B
72 "#if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ == 0)",
73 "#error Xapian no longer supports GCC < 3.1",
75 #ifndef __GXX_ABI_VERSION
76 #error GCC does not have __GXX_ABI_VERSION defined
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
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
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.",
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.",
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.
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.",
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.",
142 #ifdef XAPIAN_ENABLE_VISIBILITY
143 "/// The library was compiled with GCC's -fvisibility=hidden option.",
144 "#define XAPIAN_ENABLE_VISIBILITY",
147 "/// The version of Xapian as a C string literal.",
148 "#define XAPIAN_VERSION ", STRING_VERSION
,
150 "/** The major component of the Xapian version.",
151 " * E.g. for Xapian 1.0.14 this would be: 1",
153 "#define XAPIAN_MAJOR_VERSION ", MAJOR_VERSION
,
155 "/** The minor component of the Xapian version.",
156 " * E.g. for Xapian 1.0.14 this would be: 0",
158 "#define XAPIAN_MINOR_VERSION ", MINOR_VERSION
,
160 "/** The revision component of the Xapian version.",
161 " * E.g. for Xapian 1.0.14 this would be: 14",
163 "#define XAPIAN_REVISION ", REVISION
,
165 "/// Base (signed) type for Xapian::docid and related types.",
166 "#define XAPIAN_DOCID_BASE_TYPE ", XAPIAN_DOCID_BASE_TYPE
,
168 "/// Base (signed) type for Xapian::termcount and related types.",
169 "#define XAPIAN_TERMCOUNT_BASE_TYPE ", XAPIAN_TERMCOUNT_BASE_TYPE
,
171 "/// Base (signed) type for Xapian::termpos.",
172 "#define XAPIAN_TERMPOS_BASE_TYPE ", XAPIAN_TERMPOS_BASE_TYPE
,
174 "/// Type for returning total document length.",
175 "#define XAPIAN_TOTALLENGTH_TYPE ", XAPIAN_REVISION_TYPE
,
177 "/// Underlying type for Xapian::rev.",
178 "#define XAPIAN_REVISION_TYPE ", XAPIAN_REVISION_TYPE
,
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",
184 "/* #undef XAPIAN_HAS_CHERT_BACKEND */",
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",
191 "/* #undef XAPIAN_HAS_GLASS_BACKEND */",
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",
198 "/* #undef XAPIAN_HAS_INMEMORY_BACKEND */",
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",
205 "/* #undef XAPIAN_HAS_REMOTE_BACKEND */",
208 "/// XAPIAN_AT_LEAST(A,B,C) checks for xapian-core >= A.B.C - use like so:",
211 "/// #if XAPIAN_AT_LEAST(1,4,2)",
212 "/// /* Code needing features needing Xapian >= 1.4.2. */",
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)))))",
223 "/// We support move semantics when we're confident the compiler supports it.",
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.",
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",
240 "#endif /* XAPIAN_INCLUDED_VERSION_H */"