1 /* @(#)ccomdefs.h 1.3 03/06/15 Copyright 2000 J. Schilling */ 2 /* 3 * Various compiler dependant macros. 4 * 5 * Copyright (c) 2000 J. Schilling 6 */ 7 /* 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2, or (at your option) 11 * any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License along with 19 * this program; see the file COPYING. If not, write to the Free Software 20 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 */ 22 23 #ifndef _CCOMDEFS_H 24 #define _CCOMDEFS_H 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 /* 31 * Compiler-dependent macros to declare that functions take printf-like 32 * or scanf-like arguments. They are defined to nothing for versions of gcc 33 * that are not known to support the features properly (old versions of gcc-2 34 * didn't permit keeping the keywords out of the application namespace). 35 */ 36 #if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 7 37 38 #define __printflike__(fmtarg, firstvararg) 39 #define __printf0like__(fmtarg, firstvararg) 40 #define __scanflike__(fmtarg, firstvararg) 41 42 #else /* We found GCC that supports __attribute__ */ 43 44 #define __printflike__(fmtarg, firstvararg) \ 45 __attribute__((__format__(__printf__, fmtarg, firstvararg))) 46 #define __printf0like__(fmtarg, firstvararg) \ 47 __attribute__((__format__(__printf0__, fmtarg, firstvararg))) 48 49 /* 50 * FreeBSD GCC implements printf0 that allows the format string to 51 * be a NULL pointer. 52 */ 53 #if __FreeBSD_cc_version < 300001 54 #undef __printf0like__ 55 #define __printf0like__ __printflike__ 56 #endif 57 58 #define __scanflike__(fmtarg, firstvararg) \ 59 __attribute__((__format__(__scanf__, fmtarg, firstvararg))) 60 61 #endif /* GNUC */ 62 63 #ifdef __cplusplus 64 } 65 #endif 66 67 #endif /* _CCOMDEFS_H */ 68