Move GCC attribute declarations from pref.h.orig to new file
[pspp-builds.git] / src / libpspp / compiler.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2006 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301, USA. */
19
20 #ifndef COMPILER_H
21 #define COMPILER_H 1
22
23 /* GNU C allows the programmer to declare that certain functions take
24    printf-like arguments, never return, etc.  Conditionalize these
25    declarations on whether gcc is in use. */
26 #if __GNUC__ > 1
27 #define ATTRIBUTE(X) __attribute__ (X)
28
29 /* Only necessary because of a wart in gnulib's xalloc.h. */
30 #define __attribute__(X) __attribute__ (X)
31 #else
32 #define ATTRIBUTE(X)
33 #endif
34
35 #define UNUSED ATTRIBUTE ((unused))
36 #define NO_RETURN ATTRIBUTE ((noreturn))
37 #define PRINTF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (printf, FMT, FIRST)))
38 #define SCANF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (scanf, FMT, FIRST)))
39
40 /* This attribute was added late in the GCC 2.x cycle. */
41 #if __GNUC__ > 2
42 #define MALLOC_LIKE ATTRIBUTE ((malloc))
43 #else
44 #define MALLOC_LIKE
45 #endif
46
47 #endif /* compiler.h */