]> git.ipfire.org Git - thirdparty/gcc.git/blame - include/ansidecl.h
calls.c (special_function_p): Remove `realloc' and add `strdup' to the list of functi...
[thirdparty/gcc.git] / include / ansidecl.h
CommitLineData
6599da04 1/* ANSI and traditional C compatability macros
e428b1a8 2 Copyright 1991, 1992, 1996, 1999 Free Software Foundation, Inc.
6599da04
JM
3 This file is part of the GNU C Library.
4
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation; either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18
19/* ANSI and traditional C compatibility macros
20
21 ANSI C is assumed if __STDC__ is #defined.
22
23 Macro ANSI C definition Traditional C definition
24 ----- ---- - ---------- ----------- - ----------
25 PTR `void *' `char *'
26 LONG_DOUBLE `long double' `double'
27 VOLATILE `volatile' `'
28 SIGNED `signed' `'
29 PTRCONST `void *const' `char *'
30 ANSI_PROTOTYPES 1 not defined
31
32 CONST is also defined, but is obsolete. Just use const.
33
34 obsolete -- DEFUN (name, arglist, args)
35
36 Defines function NAME.
37
38 ARGLIST lists the arguments, separated by commas and enclosed in
39 parentheses. ARGLIST becomes the argument list in traditional C.
40
41 ARGS list the arguments with their types. It becomes a prototype in
42 ANSI C, and the type declarations in traditional C. Arguments should
43 be separated with `AND'. For functions with a variable number of
44 arguments, the last thing listed should be `DOTS'.
45
46 obsolete -- DEFUN_VOID (name)
47
48 Defines a function NAME, which takes no arguments.
49
50 obsolete -- EXFUN (name, (prototype)) -- obsolete.
51
52 Replaced by PARAMS. Do not use; will disappear someday soon.
53 Was used in external function declarations.
54 In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in
55 parentheses). In traditional C it is `NAME()'.
56 For a function that takes no arguments, PROTOTYPE should be `(void)'.
57
58 obsolete -- PROTO (type, name, (prototype) -- obsolete.
59
60 This one has also been replaced by PARAMS. Do not use.
61
62 PARAMS ((args))
63
64 We could use the EXFUN macro to handle prototype declarations, but
65 the name is misleading and the result is ugly. So we just define a
66 simple macro to handle the parameter lists, as in:
67
68 static int foo PARAMS ((int, char));
69
70 This produces: `static int foo();' or `static int foo (int, char);'
71
72 EXFUN would have done it like this:
73
74 static int EXFUN (foo, (int, char));
75
76 but the function is not external...and it's hard to visually parse
77 the function name out of the mess. EXFUN should be considered
78 obsolete; new code should be written to use PARAMS.
79
80 DOTS is also obsolete.
81
82 Examples:
83
84 extern int printf PARAMS ((const char *format, ...));
85*/
86
87#ifndef _ANSIDECL_H
88
89#define _ANSIDECL_H 1
90
91
92/* Every source file includes this file,
93 so they will all get the switch for lint. */
94/* LINTLIBRARY */
95
96
97#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32)
98/* All known AIX compilers implement these things (but don't always
99 define __STDC__). The RISC/OS MIPS compiler defines these things
100 in SVR4 mode, but does not define __STDC__. */
101
102#define PTR void *
103#define PTRCONST void *CONST
104#define LONG_DOUBLE long double
105
de5809b9 106#ifndef IN_GCC
6599da04
JM
107#define AND ,
108#define NOARGS void
109#define VOLATILE volatile
110#define SIGNED signed
de5809b9 111#endif /* ! IN_GCC */
6599da04
JM
112
113#define PARAMS(paramlist) paramlist
114#define ANSI_PROTOTYPES 1
115
116#define VPARAMS(ARGS) ARGS
117#define VA_START(va_list,var) va_start(va_list,var)
118
119/* These are obsolete. Do not use. */
de5809b9 120#ifndef IN_GCC
6599da04
JM
121#define CONST const
122#define DOTS , ...
123#define PROTO(type, name, arglist) type name arglist
124#define EXFUN(name, proto) name proto
125#define DEFUN(name, arglist, args) name(args)
126#define DEFUN_VOID(name) name(void)
de5809b9 127#endif /* ! IN_GCC */
6599da04
JM
128
129#else /* Not ANSI C. */
130
131#define PTR char *
132#define PTRCONST PTR
133#define LONG_DOUBLE double
134
de5809b9 135#ifndef IN_GCC
6599da04
JM
136#define AND ;
137#define NOARGS
de5809b9
KG
138#define VOLATILE
139#define SIGNED
140#endif /* !IN_GCC */
141
6599da04
JM
142#ifndef const /* some systems define it in header files for non-ansi mode */
143#define const
144#endif
6599da04
JM
145
146#define PARAMS(paramlist) ()
147
148#define VPARAMS(ARGS) (va_alist) va_dcl
149#define VA_START(va_list,var) va_start(va_list)
150
151/* These are obsolete. Do not use. */
de5809b9 152#ifndef IN_GCC
6599da04
JM
153#define CONST
154#define DOTS
155#define PROTO(type, name, arglist) type name ()
156#define EXFUN(name, proto) name()
157#define DEFUN(name, arglist, args) name arglist args;
158#define DEFUN_VOID(name) name()
de5809b9 159#endif /* ! IN_GCC */
6599da04
JM
160
161#endif /* ANSI C. */
162
6c9821b7
PDM
163
164/* Using MACRO(x,y) in cpp #if conditionals does not work with some
165 older preprocessors. Thus we can't define something like this:
166
b30bce6b
KG
167#define HAVE_GCC_VERSION(MAJOR, MINOR) \
168 (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
6c9821b7
PDM
169
170and then test "#if HAVE_GCC_VERSION(2,7)".
171
172So instead we use the macro below and test it against specific values. */
173
174/* This macro simplifies testing whether we are using gcc, and if it
175 is of a particular minimum version. (Both major & minor numbers are
176 significant.) This macro will evaluate to 0 if we are not using
177 gcc at all. */
178#ifndef GCC_VERSION
179#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
180#endif /* GCC_VERSION */
b30bce6b 181
e428b1a8
ILT
182/* Define macros for some gcc attributes. This permits us to use the
183 macros freely, and know that they will come into play for the
184 version of gcc in which they are supported. */
185
6c9821b7 186#if (GCC_VERSION < 2007)
e428b1a8
ILT
187# define __attribute__(x)
188#endif
189
6c9821b7 190/* Attributes on labels were valid as of gcc 2.93. */
e428b1a8 191#ifndef ATTRIBUTE_UNUSED_LABEL
6c9821b7 192# if (GCC_VERSION >= 2093)
e428b1a8 193# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
6c9821b7
PDM
194# else
195# define ATTRIBUTE_UNUSED_LABEL
196# endif /* GNUC >= 2.93 */
e428b1a8
ILT
197#endif /* ATTRIBUTE_UNUSED_LABEL */
198
199#ifndef ATTRIBUTE_UNUSED
200#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
201#endif /* ATTRIBUTE_UNUSED */
202
203#ifndef ATTRIBUTE_NORETURN
204#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
205#endif /* ATTRIBUTE_NORETURN */
206
207#ifndef ATTRIBUTE_PRINTF
b30bce6b 208#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
e428b1a8
ILT
209#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
210#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
211#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
212#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
213#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
214#endif /* ATTRIBUTE_PRINTF */
215
6599da04 216#endif /* ansidecl.h */