1 |
cebix |
1.1 |
/* ANSI and traditional C compatability macros |
2 |
|
|
Copyright 1991, 1992, 1996 Free Software Foundation, Inc. |
3 |
|
|
This file is part of the GNU C Library. |
4 |
|
|
|
5 |
|
|
This program is free software; you can redistribute it and/or modify |
6 |
|
|
it under the terms of the GNU General Public License as published by |
7 |
|
|
the Free Software Foundation; either version 2 of the License, or |
8 |
|
|
(at your option) any later version. |
9 |
|
|
|
10 |
|
|
This program is distributed in the hope that it will be useful, |
11 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
|
|
GNU General Public License for more details. |
14 |
|
|
|
15 |
|
|
You should have received a copy of the GNU General Public License |
16 |
|
|
along with this program; if not, write to the Free Software |
17 |
|
|
Foundation, 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 |
|
|
|
106 |
|
|
#define AND , |
107 |
|
|
#define NOARGS void |
108 |
|
|
#define VOLATILE volatile |
109 |
|
|
#define SIGNED signed |
110 |
|
|
|
111 |
|
|
#define PARAMS(paramlist) paramlist |
112 |
|
|
#define ANSI_PROTOTYPES 1 |
113 |
|
|
|
114 |
|
|
#define VPARAMS(ARGS) ARGS |
115 |
|
|
#define VA_START(va_list,var) va_start(va_list,var) |
116 |
|
|
|
117 |
|
|
/* These are obsolete. Do not use. */ |
118 |
|
|
#define CONST const |
119 |
|
|
#define DOTS , ... |
120 |
|
|
#define PROTO(type, name, arglist) type name arglist |
121 |
|
|
#define EXFUN(name, proto) name proto |
122 |
|
|
#define DEFUN(name, arglist, args) name(args) |
123 |
|
|
#define DEFUN_VOID(name) name(void) |
124 |
|
|
|
125 |
|
|
#else /* Not ANSI C. */ |
126 |
|
|
|
127 |
|
|
#define PTR char * |
128 |
|
|
#define PTRCONST PTR |
129 |
|
|
#define LONG_DOUBLE double |
130 |
|
|
|
131 |
|
|
#define AND ; |
132 |
|
|
#define NOARGS |
133 |
|
|
#ifndef const /* some systems define it in header files for non-ansi mode */ |
134 |
|
|
#define const |
135 |
|
|
#endif |
136 |
|
|
#define VOLATILE |
137 |
|
|
#define SIGNED |
138 |
|
|
|
139 |
|
|
#define PARAMS(paramlist) () |
140 |
|
|
|
141 |
|
|
#define VPARAMS(ARGS) (va_alist) va_dcl |
142 |
|
|
#define VA_START(va_list,var) va_start(va_list) |
143 |
|
|
|
144 |
|
|
/* These are obsolete. Do not use. */ |
145 |
|
|
#define CONST |
146 |
|
|
#define DOTS |
147 |
|
|
#define PROTO(type, name, arglist) type name () |
148 |
|
|
#define EXFUN(name, proto) name() |
149 |
|
|
#define DEFUN(name, arglist, args) name arglist args; |
150 |
|
|
#define DEFUN_VOID(name) name() |
151 |
|
|
|
152 |
|
|
#endif /* ANSI C. */ |
153 |
|
|
|
154 |
|
|
#endif /* ansidecl.h */ |