MPD

src/gcc.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003-2010 The Music Player Daemon Project
00003  * http://www.musicpd.org
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, write to the Free Software Foundation, Inc.,
00017  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 
00020 #ifndef MPD_GCC_H
00021 #define MPD_GCC_H
00022 
00023 /* this allows us to take advantage of special gcc features while still
00024  * allowing other compilers to compile:
00025  *
00026  * example taken from: http://rlove.org/log/2005102601
00027  */
00028 
00029 #if defined(__GNUC__) && (__GNUC__ >= 3)
00030 #  define mpd_must_check        __attribute__ ((warn_unused_result))
00031 #  define mpd_packed            __attribute__ ((packed))
00032 /* these are very useful for type checking */
00033 #  define mpd_printf            __attribute__ ((format(printf,1,2)))
00034 #  define mpd_fprintf           __attribute__ ((format(printf,2,3)))
00035 #  define mpd_fprintf_          __attribute__ ((format(printf,3,4)))
00036 #  define mpd_fprintf__         __attribute__ ((format(printf,4,5)))
00037 #  define mpd_scanf             __attribute__ ((format(scanf,1,2)))
00038 #  define mpd_used              __attribute__ ((used))
00039 /* #  define inline     inline __attribute__ ((always_inline)) */
00040 #  define mpd_noinline          __attribute__ ((noinline))
00041 #else
00042 #  define mpd_must_check
00043 #  define mpd_packed
00044 #  define mpd_printf
00045 #  define mpd_fprintf
00046 #  define mpd_fprintf_
00047 #  define mpd_fprintf__
00048 #  define mpd_scanf
00049 #  define mpd_used
00050 /* #  define inline */
00051 #  define mpd_noinline
00052 #endif
00053 
00054 #endif /* MPD_GCC_H */