Website now in git not CVS
[xapian.git] / xapian-core / common / noreturn.h
blob665f94bef12a754cc6369268708e2d61ca028987
1 /** @file noreturn.h
2 * @brief Define the XAPIAN_NORETURN macro.
3 */
4 /* Copyright (C) 2007,2011 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef XAPIAN_INCLUDED_NORETURN_H
22 #define XAPIAN_INCLUDED_NORETURN_H
24 // The macro needs to be applied to a declaration, so use it like so:
26 // XAPIAN_NORETURN(static void throw_read_only());
27 // static void
28 // throw_read_only()
29 // {
30 // throw Xapian::InvalidOperationError("Server is read-only");
31 // }
33 // Allow the user to override XAPIAN_NORETURN on the compiler command line.
34 #ifndef XAPIAN_NORETURN
35 # if defined __GNUC__
36 // __attribute__((__noreturn__)) is supported by GCC 2.5 and later so there's
37 // no need to check the GCC version in use.
38 # define XAPIAN_NORETURN(D) D __attribute__((__noreturn__))
39 # elif defined _MSC_VER && _MSC_VER >= 1300
40 // __declspec(noreturn) appears to be supported by MSVC 7.0 and later.
41 # define XAPIAN_NORETURN(D) __declspec(noreturn) D
42 # else
43 # define XAPIAN_NORETURN(D) D
44 # endif
45 #endif
47 #endif // XAPIAN_INCLUDED_NORETURN_H