1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* ANSI and traditional C compatibility macros
3 Copyright 1991, 1992 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
8 /* ANSI and traditional C compatibility macros
10 ANSI C is assumed if __STDC__ is #defined.
12 Macro ANSI C definition Traditional C definition
13 ----- ---- - ---------- ----------- - ----------
15 LONG_DOUBLE `long double' `double'
16 VOLATILE `volatile' `'
18 PTRCONST `void *const' `char *'
19 ANSI_PROTOTYPES 1 not defined
21 CONST is also defined, but is obsolete. Just use const.
23 DEFUN (name, arglist, args)
25 Defines function NAME.
27 ARGLIST lists the arguments, separated by commas and enclosed in
28 parentheses. ARGLIST becomes the argument list in traditional C.
30 ARGS list the arguments with their types. It becomes a prototype in
31 ANSI C, and the type declarations in traditional C. Arguments should
32 be separated with `AND'. For functions with a variable number of
33 arguments, the last thing listed should be `DOTS'.
37 Defines a function NAME, which takes no arguments.
39 obsolete -- EXFUN (name, (prototype)) -- obsolete.
41 Replaced by PARAMS. Do not use; will disappear someday soon.
42 Was used in external function declarations.
43 In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in
44 parentheses). In traditional C it is `NAME()'.
45 For a function that takes no arguments, PROTOTYPE should be `(void)'.
49 We could use the EXFUN macro to handle prototype declarations, but
50 the name is misleading and the result is ugly. So we just define a
51 simple macro to handle the parameter lists, as in:
53 static int foo PARAMS ((int, char));
55 This produces: `static int foo();' or `static int foo (int, char);'
57 EXFUN would have done it like this:
59 static int EXFUN (foo, (int, char));
61 but the function is not external...and it's hard to visually parse
62 the function name out of the mess. EXFUN should be considered
63 obsolete; new code should be written to use PARAMS.
66 extern int printf PARAMS ((CONST char *format DOTS));
67 int DEFUN(fprintf, (stream, format),
68 FILE *stream AND CONST char *format DOTS) { ... }
69 void DEFUN_VOID(abort) { ... }
77 /* Every source file includes this file,
78 so they will all get the switch for lint. */
82 #if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32)
83 /* All known AIX compilers implement these things (but don't always
84 define __STDC__). The RISC/OS MIPS compiler defines these things
85 in SVR4 mode, but does not define __STDC__. */
88 #define PTRCONST void *CONST
89 #define LONG_DOUBLE long double
94 #define VOLATILE volatile
98 #define EXFUN(name, proto) name proto
99 #define DEFUN(name, arglist, args) name(args)
100 #define DEFUN_VOID(name) name(void)
102 #define PROTO(type, name, arglist) type name arglist
103 #define PARAMS(paramlist) paramlist
104 #define ANSI_PROTOTYPES 1
106 #else /* Not ANSI C. */
110 #define LONG_DOUBLE double
115 #ifndef const /* some systems define it in header files for non-ansi mode */
122 #define EXFUN(name, proto) name()
123 #define DEFUN(name, arglist, args) name arglist args;
124 #define DEFUN_VOID(name) name()
125 #define PROTO(type, name, arglist) type name ()
126 #define PARAMS(paramlist) ()
130 #endif /* ansidecl.h */