source: roaraudio/include/roaraudio/compilerhacks.h @ 5200:8648a10bca82

Last change on this file since 5200:8648a10bca82 was 5200:8648a10bca82, checked in by phi, 13 years ago

gcc is bad, attribute((nonnull)) changes optimizer behavor

File size: 2.5 KB
Line 
1//compilerhacks.h:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011
5 *
6 *  This file is part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU Lesser General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  RoarAudio is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU Lesser General Public License for more details.
18 *
19 *  You should have received a copy of the GNU Lesser General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 *  NOTE: Even though this file is LGPLed it (may) include GPLed files
25 *  so the license of this file is/may therefore downgraded to GPL.
26 *  See HACKING for details.
27 */
28
29#ifndef _ROARAUDIO_COMPILERHACKS_H_
30#define _ROARAUDIO_COMPILERHACKS_H_
31
32#if defined(__GNUC__) && __GNUC__ >= 4
33#define _LIBROAR_ATTR_DEPRECATED        __attribute__((deprecated))
34#define _LIBROAR_ATTR_PURE              __attribute__ ((pure))
35#define _LIBROAR_ATTR_USE_RESULT        __attribute__ ((warn_unused_result))
36
37// gcc does not only add a warning on NULL argument for the following
38// but also asumes they are never NULL (but alloes them to be NULL)
39// and breaks our check this way.
40#if 0
41#define _LIBROAR_ATTR_NONNULL(x, index...) __attribute__((nonnull ( x, ##index )))
42#define _LIBROAR_ATTR_NONNULL_ALL       __attribute__((nonnull))
43#endif
44#endif
45
46// add more defintions for other compilers here.
47
48
49
50#ifndef _LIBROAR_ATTR_DEPRECATED
51#define _LIBROAR_ATTR_DEPRECATED
52#endif
53#ifndef _LIBROAR_ATTR_NONNULL
54#define _LIBROAR_ATTR_NONNULL(index...)
55#endif
56#ifndef _LIBROAR_ATTR_NONNULL_ALL
57#define _LIBROAR_ATTR_NONNULL_ALL
58#endif
59#ifndef _LIBROAR_ATTR_PURE
60#define _LIBROAR_ATTR_PURE
61#endif
62#ifndef _LIBROAR_ATTR_USE_RESULT
63#define _LIBROAR_ATTR_USE_RESULT
64#endif
65
66#ifndef _LIBROAR_IGNORE_RET
67#define _LIBROAR_IGNORE_RET(x) ((void)((x)+1))
68#endif
69
70#ifndef _LIBROAR_NOATTR_TO_STATIC
71#define _LIBROAR_ATTR_TO_STATIC _LIBROAR_ATTR_DEPRECATED
72#else
73#define _LIBROAR_ATTR_TO_STATIC
74#endif
75
76#ifdef _LIBROAR_NOATTR_WARNINGS
77#undef _LIBROAR_ATTR_DEPRECATED
78#define _LIBROAR_ATTR_DEPRECATED
79#undef _LIBROAR_ATTR_USE_RESULT
80#define _LIBROAR_ATTR_USE_RESULT
81#endif
82
83#endif
84
85//ll
Note: See TracBrowser for help on using the repository browser.