source: trunk/emx/src/emxexp/ansidecl.h@ 3669

Last change on this file since 3669 was 18, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 4.2 KB
Line 
1/* ANSI and traditional C compatability macros
2 Copyright 1991, 1992 Free Software Foundation, Inc.
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 VOLATILE `volatile' `'
28 SIGNED `signed' `'
29 PTRCONST `void *const' `char *'
30
31 CONST is also defined, but is obsolete. Just use const.
32
33 DEFUN (name, arglist, args)
34
35 Defines function NAME.
36
37 ARGLIST lists the arguments, separated by commas and enclosed in
38 parentheses. ARGLIST becomes the argument list in traditional C.
39
40 ARGS list the arguments with their types. It becomes a prototype in
41 ANSI C, and the type declarations in traditional C. Arguments should
42 be separated with `AND'. For functions with a variable number of
43 arguments, the last thing listed should be `DOTS'.
44
45 DEFUN_VOID (name)
46
47 Defines a function NAME, which takes no arguments.
48
49 obsolete -- EXFUN (name, (prototype)) -- obsolete.
50
51 Replaced by PARAMS. Do not use; will disappear someday soon.
52 Was used in external function declarations.
53 In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in
54 parentheses). In traditional C it is `NAME()'.
55 For a function that takes no arguments, PROTOTYPE should be `(void)'.
56
57 PARAMS ((args))
58
59 We could use the EXFUN macro to handle prototype declarations, but
60 the name is misleading and the result is ugly. So we just define a
61 simple macro to handle the parameter lists, as in:
62
63 static int foo PARAMS ((int, char));
64
65 This produces: `static int foo();' or `static int foo (int, char);'
66
67 EXFUN would have done it like this:
68
69 static int EXFUN (foo, (int, char));
70
71 but the function is not external...and it's hard to visually parse
72 the function name out of the mess. EXFUN should be considered
73 obsolete; new code should be written to use PARAMS.
74
75 For example:
76 extern int printf PARAMS ((CONST char *format DOTS));
77 int DEFUN(fprintf, (stream, format),
78 FILE *stream AND CONST char *format DOTS) { ... }
79 void DEFUN_VOID(abort) { ... }
80*/
81
82#ifndef _ANSIDECL_H
83
84#define _ANSIDECL_H 1
85
86
87/* Every source file includes this file,
88 so they will all get the switch for lint. */
89/* LINTLIBRARY */
90
91
92#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4))
93/* All known AIX compilers implement these things (but don't always
94 define __STDC__). The RISC/OS MIPS compiler defines these things
95 in SVR4 mode, but does not define __STDC__. */
96
97#define PTR void *
98#define PTRCONST void *CONST
99#define LONG_DOUBLE long double
100
101#define AND ,
102#define NOARGS void
103#define CONST const
104#define VOLATILE volatile
105#define SIGNED signed
106#define DOTS , ...
107
108#define EXFUN(name, proto) name proto
109#define DEFUN(name, arglist, args) name(args)
110#define DEFUN_VOID(name) name(void)
111
112#define PROTO(type, name, arglist) type name arglist
113#define PARAMS(paramlist) paramlist
114
115#else /* Not ANSI C. */
116
117#define PTR char *
118#define PTRCONST PTR
119#define LONG_DOUBLE double
120
121#define AND ;
122#define NOARGS
123#define CONST
124#ifndef const /* some systems define it in header files for non-ansi mode */
125#define const
126#endif
127#define VOLATILE
128#define SIGNED
129#define DOTS
130
131#define EXFUN(name, proto) name()
132#define DEFUN(name, arglist, args) name arglist args;
133#define DEFUN_VOID(name) name()
134#define PROTO(type, name, arglist) type name ()
135#define PARAMS(paramlist) ()
136
137#endif /* ANSI C. */
138
139#endif /* ansidecl.h */
Note: See TracBrowser for help on using the repository browser.