]> git.meshlink.io Git - catta/blob - include/catta/gccmacro.h
rename everything avahi to catta
[catta] / include / catta / gccmacro.h
1 #ifndef foogccmacrohfoo
2 #define foogccmacrohfoo
3
4 /***
5   This file is part of catta.
6
7   catta is free software; you can redistribute it and/or modify it
8   under the terms of the GNU Lesser General Public License as
9   published by the Free Software Foundation; either version 2.1 of the
10   License, or (at your option) any later version.
11
12   catta is distributed in the hope that it will be useful, but WITHOUT
13   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15   Public License for more details.
16
17   You should have received a copy of the GNU Lesser General Public
18   License along with catta; if not, write to the Free Software
19   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20   USA.
21 ***/
22
23 /** \file gccmacro.h Defines some macros for GCC extensions */
24
25 #include <catta/cdecl.h>
26
27 CATTA_C_DECL_BEGIN
28
29 #if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
30 #define CATTA_GCC_ALLOC_SIZE(x) __attribute__ ((__alloc_size__(x)))
31 #define CATTA_GCC_ALLOC_SIZE2(x,y) __attribute__ ((__alloc_size__(x,y)))
32 #else
33 /** Macro for usage of GCC's alloc_size attribute */
34 #define CATTA_GCC_ALLOC_SIZE(x)
35 #define CATTA_GCC_ALLOC_SIZE2(x,y)
36 #endif
37
38 #if defined(__GNUC__) && (__GNUC__ >= 4)
39 #define CATTA_GCC_SENTINEL __attribute__ ((sentinel))
40 #else
41 /** Macro for usage of GCC's sentinel compilation warnings */
42 #define CATTA_GCC_SENTINEL
43 #endif
44
45 #ifdef __GNUC__
46 #define CATTA_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
47 #else
48 /** Macro for usage of GCC's printf compilation warnings */
49 #define CATTA_GCC_PRINTF_ATTR(a,b)
50 #endif
51
52 /** Same as CATTA_GCC_PRINTF_ATTR but hard coded to arguments 1 and 2 */
53 #define CATTA_GCC_PRINTF_ATTR12 CATTA_GCC_PRINTF_ATTR(1,2)
54
55 /** Same as CATTA_GCC_PRINTF_ATTR but hard coded to arguments 2 and 3 */
56 #define CATTA_GCC_PRINTF_ATTR23 CATTA_GCC_PRINTF_ATTR(2,3)
57
58 #ifdef __GNUC__
59 #define CATTA_GCC_NORETURN __attribute__((noreturn))
60 #else
61 /** Macro for no-return functions */
62 #define CATTA_GCC_NORETURN
63 #endif
64
65 #ifdef __GNUC__
66 #define CATTA_GCC_UNUSED __attribute__ ((unused))
67 #else
68 /** Macro for not used parameter */
69 #define CATTA_GCC_UNUSED
70 #endif
71
72 CATTA_C_DECL_END
73
74 #endif