]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - include/ansidecl.h
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / include / ansidecl.h
CommitLineData
ee7d7cd8 1/* ANSI and traditional C compatability macros
01b4d318 2 Copyright 1991, 1992 Free Software Foundation, Inc.
ee7d7cd8
SC
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., 675 Mass Ave, Cambridge, MA 02139, 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 CONST `const' `'
28 VOLATILE `volatile' `'
29 SIGNED `signed' `'
30 PTRCONST `void *const' `char *'
31
01b4d318 32 DEFUN (name, arglist, args)
ee7d7cd8
SC
33
34 Defines function NAME.
35
36 ARGLIST lists the arguments, separated by commas and enclosed in
37 parentheses. ARGLIST becomes the argument list in traditional C.
38
39 ARGS list the arguments with their types. It becomes a prototype in
40 ANSI C, and the type declarations in traditional C. Arguments should
41 be separated with `AND'. For functions with a variable number of
42 arguments, the last thing listed should be `DOTS'.
43
01b4d318 44 DEFUN_VOID (name)
ee7d7cd8
SC
45
46 Defines a function NAME, which takes no arguments.
47
01b4d318 48 obsolete -- EXFUN (name, (prototype)) -- obsolete.
ee7d7cd8 49
01b4d318
JK
50 Replaced by PARAMS. Do not use; will disappear someday soon.
51 Was used in external function declarations.
52 In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in
ee7d7cd8 53 parentheses). In traditional C it is `NAME()'.
01b4d318
JK
54 For a function that takes no arguments, PROTOTYPE should be `(void)'.
55
56 PARAMS ((args))
57
58 We could use the EXFUN macro to handle prototype declarations, but
59 the name is misleading and the result is ugly. So we just define a
60 simple macro to handle the parameter lists, as in:
61
62 static int foo PARAMS ((int, char));
63
64 This produces: `static int foo();' or `static int foo (int, char);'
65
66 EXFUN would have done it like this:
67
68 static int EXFUN (foo, (int, char));
69
70 but the function is not external...and it's hard to visually parse
71 the function name out of the mess. EXFUN should be considered
72 obsolete; new code should be written to use PARAMS.
ee7d7cd8
SC
73
74 For example:
01b4d318 75 extern int printf PARAMS ((CONST char *format DOTS));
ee7d7cd8
SC
76 int DEFUN(fprintf, (stream, format),
77 FILE *stream AND CONST char *format DOTS) { ... }
78 void DEFUN_VOID(abort) { ... }
79*/
80
81#ifndef _ANSIDECL_H
82
83#define _ANSIDECL_H 1
84
85
86/* Every source file includes this file,
87 so they will all get the switch for lint. */
88/* LINTLIBRARY */
89
90
01b4d318
JK
91#if defined (__STDC__) || defined (_AIX)
92/* the AIX xlc compiler implements all these things even when it is in
93 a mode which doesn't define __STDC__. */
ee7d7cd8
SC
94
95#define PTR void *
96#define PTRCONST void *CONST
97#define LONG_DOUBLE long double
98
99#define AND ,
100#define NOARGS void
101#define CONST const
102#define VOLATILE volatile
103#define SIGNED signed
104#define DOTS , ...
105
106#define EXFUN(name, proto) name proto
107#define DEFUN(name, arglist, args) name(args)
01b4d318 108#define DEFUN_VOID(name) name(void)
ee7d7cd8 109
01b4d318
JK
110#define PROTO(type, name, arglist) type name arglist
111#define PARAMS(paramlist) paramlist
ee7d7cd8
SC
112
113#else /* Not ANSI C. */
114
115#define PTR char *
116#define PTRCONST PTR
117#define LONG_DOUBLE double
118
119#define AND ;
120#define NOARGS
121#define CONST
122#define VOLATILE
123#define SIGNED
124#define DOTS
125
126#define EXFUN(name, proto) name()
127#define DEFUN(name, arglist, args) name arglist args;
128#define DEFUN_VOID(name) name()
129#define PROTO(type, name, arglist) type name ()
01b4d318 130#define PARAMS(paramlist) ()
ee7d7cd8 131
01b4d318 132#endif /* ANSI C. */
ee7d7cd8
SC
133
134#endif /* ansidecl.h */