1*c2c66affSColin Finck /* @(#)ccomdefs.h	1.12 11/07/21 Copyright 2000-2011 J. Schilling */
2*c2c66affSColin Finck /*
3*c2c66affSColin Finck  *	Various compiler dependant macros.
4*c2c66affSColin Finck  *
5*c2c66affSColin Finck  *	Copyright (c) 2000-2011 J. Schilling
6*c2c66affSColin Finck  */
7*c2c66affSColin Finck /*
8*c2c66affSColin Finck  * The contents of this file are subject to the terms of the
9*c2c66affSColin Finck  * Common Development and Distribution License, Version 1.0 only
10*c2c66affSColin Finck  * (the "License").  You may not use this file except in compliance
11*c2c66affSColin Finck  * with the License.
12*c2c66affSColin Finck  *
13*c2c66affSColin Finck  * See the file CDDL.Schily.txt in this distribution for details.
14*c2c66affSColin Finck  *
15*c2c66affSColin Finck  * When distributing Covered Code, include this CDDL HEADER in each
16*c2c66affSColin Finck  * file and include the License file CDDL.Schily.txt from this distribution.
17*c2c66affSColin Finck  */
18*c2c66affSColin Finck 
19*c2c66affSColin Finck #ifndef _SCHILY_CCOMDEFS_H
20*c2c66affSColin Finck #define	_SCHILY_CCOMDEFS_H
21*c2c66affSColin Finck 
22*c2c66affSColin Finck #ifndef _SCHILY_MCONFIG_H
23*c2c66affSColin Finck #include <schily/mconfig.h>
24*c2c66affSColin Finck #endif
25*c2c66affSColin Finck 
26*c2c66affSColin Finck #ifdef	__cplusplus
27*c2c66affSColin Finck extern "C" {
28*c2c66affSColin Finck #endif
29*c2c66affSColin Finck 
30*c2c66affSColin Finck /*
31*c2c66affSColin Finck  * Compiler-dependent macros to declare that functions take printf-like
32*c2c66affSColin Finck  * or scanf-like arguments. They are defined to nothing for versions of gcc
33*c2c66affSColin Finck  * that are not known to support the features properly (old versions of gcc-2
34*c2c66affSColin Finck  * didn't permit keeping the keywords out of the application namespace).
35*c2c66affSColin Finck  */
36*c2c66affSColin Finck #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \
37*c2c66affSColin Finck 	defined(NO_PRINTFLIKE)
38*c2c66affSColin Finck 
39*c2c66affSColin Finck #define	__printflike__(fmtarg, firstvararg)
40*c2c66affSColin Finck #define	__printf0like__(fmtarg, firstvararg)
41*c2c66affSColin Finck #define	__scanflike__(fmtarg, firstvararg)
42*c2c66affSColin Finck 
43*c2c66affSColin Finck #else /* We found GCC that supports __attribute__ */
44*c2c66affSColin Finck 
45*c2c66affSColin Finck #define	__printflike__(fmtarg, firstvararg) \
46*c2c66affSColin Finck 		__attribute__((__format__(__printf__, fmtarg, firstvararg)))
47*c2c66affSColin Finck #define	__printf0like__(fmtarg, firstvararg) \
48*c2c66affSColin Finck 		__attribute__((__format__(__printf0__, fmtarg, firstvararg)))
49*c2c66affSColin Finck 
50*c2c66affSColin Finck /*
51*c2c66affSColin Finck  * FreeBSD GCC implements printf0 that allows the format string to
52*c2c66affSColin Finck  * be a NULL pointer.
53*c2c66affSColin Finck  */
54*c2c66affSColin Finck #if	__FreeBSD_cc_version < 300001
55*c2c66affSColin Finck #undef	__printf0like__
56*c2c66affSColin Finck #define	__printf0like__	__printflike__
57*c2c66affSColin Finck #endif
58*c2c66affSColin Finck 
59*c2c66affSColin Finck #define	__scanflike__(fmtarg, firstvararg) \
60*c2c66affSColin Finck 		__attribute__((__format__(__scanf__, fmtarg, firstvararg)))
61*c2c66affSColin Finck 
62*c2c66affSColin Finck #endif /* GNUC */
63*c2c66affSColin Finck 
64*c2c66affSColin Finck #if __GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 2
65*c2c66affSColin Finck /* GCC-3.3 or more */
66*c2c66affSColin Finck 
67*c2c66affSColin Finck /* CSTYLED */
68*c2c66affSColin Finck #define	UConst	__attribute__ ((__used__)) const
69*c2c66affSColin Finck 
70*c2c66affSColin Finck #else	/* less than GNUC 3.3 */
71*c2c66affSColin Finck 
72*c2c66affSColin Finck #define	UConst	const
73*c2c66affSColin Finck 
74*c2c66affSColin Finck #endif /* less than GNUC 3.3 */
75*c2c66affSColin Finck 
76*c2c66affSColin Finck #ifdef	__PCC__
77*c2c66affSColin Finck /*
78*c2c66affSColin Finck  * Hack until pcc supports __attribute__ ((__used__))
79*c2c66affSColin Finck  */
80*c2c66affSColin Finck #ifdef	UConst
81*c2c66affSColin Finck #undef	UConst
82*c2c66affSColin Finck #define	UConst	const
83*c2c66affSColin Finck #endif
84*c2c66affSColin Finck #endif
85*c2c66affSColin Finck 
86*c2c66affSColin Finck #ifdef	__cplusplus
87*c2c66affSColin Finck }
88*c2c66affSColin Finck #endif
89*c2c66affSColin Finck 
90*c2c66affSColin Finck #endif	/* _SCHILY_CCOMDEFS_H */
91