Debian Codegraph @

lib/warn_unused_result.h

raw symbols SCIP
1 /*
2 * fstrcmp - fuzzy string compare library
3 * Copyright (C) 2009 Peter Miller
4 * Written by Peter Miller <[email protected]>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
10 *
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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef LIB_WARN_UNUSED_RESULT_H
21 #define LIB_WARN_UNUSED_RESULT_H
22
23 /*
24 * Convenience macros to test the versions of glibc and gcc.
25 * Use them like this:
26 * #if __GNUC_PREREQ (2,8)
27 * ... code requiring gcc 2.8 or later ...
28 * #endif
29 * Note - they won't work for gcc1 or glibc1, since the _MINOR macros
30 * were not defined then. */
31 #if defined __GNUC__ && defined __GNUC_MINOR__
32 # define LIB_GNUC_PREREQ(maj, min) \
33 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
34 #else
35 # define LIB_GNUC_PREREQ(maj, min) 0
36 #endif
37
38 /*
39 * We attach this attribute to functions that should never have their
40 * return value ignored. Amongst other things, this can detect the case
41 * where the client has called explain_fubar when they meant to call
42 * explain_fubar_or_die instead.
43 */
44 #if LIB_GNUC_PREREQ(3, 4)
45 #define LIB_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
46 #else
47 #define LIB_WARN_UNUSED_RESULT
48 #endif
49
50 #endif /* LIB_WARN_UNUSED_RESULT_H */