1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*4882a593Smuzhiyun /* ANSI and traditional C compatibility macros 3*4882a593Smuzhiyun Copyright 1991, 1992 Free Software Foundation, Inc. 4*4882a593Smuzhiyun This file is part of the GNU C Library. 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun /* ANSI and traditional C compatibility macros 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun ANSI C is assumed if __STDC__ is #defined. 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun Macro ANSI C definition Traditional C definition 13*4882a593Smuzhiyun ----- ---- - ---------- ----------- - ---------- 14*4882a593Smuzhiyun PTR `void *' `char *' 15*4882a593Smuzhiyun LONG_DOUBLE `long double' `double' 16*4882a593Smuzhiyun VOLATILE `volatile' `' 17*4882a593Smuzhiyun SIGNED `signed' `' 18*4882a593Smuzhiyun PTRCONST `void *const' `char *' 19*4882a593Smuzhiyun ANSI_PROTOTYPES 1 not defined 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun CONST is also defined, but is obsolete. Just use const. 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun DEFUN (name, arglist, args) 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun Defines function NAME. 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun ARGLIST lists the arguments, separated by commas and enclosed in 28*4882a593Smuzhiyun parentheses. ARGLIST becomes the argument list in traditional C. 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun ARGS list the arguments with their types. It becomes a prototype in 31*4882a593Smuzhiyun ANSI C, and the type declarations in traditional C. Arguments should 32*4882a593Smuzhiyun be separated with `AND'. For functions with a variable number of 33*4882a593Smuzhiyun arguments, the last thing listed should be `DOTS'. 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun DEFUN_VOID (name) 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun Defines a function NAME, which takes no arguments. 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun obsolete -- EXFUN (name, (prototype)) -- obsolete. 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun Replaced by PARAMS. Do not use; will disappear someday soon. 42*4882a593Smuzhiyun Was used in external function declarations. 43*4882a593Smuzhiyun In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in 44*4882a593Smuzhiyun parentheses). In traditional C it is `NAME()'. 45*4882a593Smuzhiyun For a function that takes no arguments, PROTOTYPE should be `(void)'. 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun PARAMS ((args)) 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun We could use the EXFUN macro to handle prototype declarations, but 50*4882a593Smuzhiyun the name is misleading and the result is ugly. So we just define a 51*4882a593Smuzhiyun simple macro to handle the parameter lists, as in: 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun static int foo PARAMS ((int, char)); 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun This produces: `static int foo();' or `static int foo (int, char);' 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun EXFUN would have done it like this: 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun static int EXFUN (foo, (int, char)); 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun but the function is not external...and it's hard to visually parse 62*4882a593Smuzhiyun the function name out of the mess. EXFUN should be considered 63*4882a593Smuzhiyun obsolete; new code should be written to use PARAMS. 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun For example: 66*4882a593Smuzhiyun extern int printf PARAMS ((CONST char *format DOTS)); 67*4882a593Smuzhiyun int DEFUN(fprintf, (stream, format), 68*4882a593Smuzhiyun FILE *stream AND CONST char *format DOTS) { ... } 69*4882a593Smuzhiyun void DEFUN_VOID(abort) { ... } 70*4882a593Smuzhiyun */ 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun #ifndef _ANSIDECL_H 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun #define _ANSIDECL_H 1 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun /* Every source file includes this file, 78*4882a593Smuzhiyun so they will all get the switch for lint. */ 79*4882a593Smuzhiyun /* LINTLIBRARY */ 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun 82*4882a593Smuzhiyun #if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32) 83*4882a593Smuzhiyun /* All known AIX compilers implement these things (but don't always 84*4882a593Smuzhiyun define __STDC__). The RISC/OS MIPS compiler defines these things 85*4882a593Smuzhiyun in SVR4 mode, but does not define __STDC__. */ 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun #define PTR void * 88*4882a593Smuzhiyun #define PTRCONST void *CONST 89*4882a593Smuzhiyun #define LONG_DOUBLE long double 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun #define AND , 92*4882a593Smuzhiyun #define NOARGS void 93*4882a593Smuzhiyun #define CONST const 94*4882a593Smuzhiyun #define VOLATILE volatile 95*4882a593Smuzhiyun #define SIGNED signed 96*4882a593Smuzhiyun #define DOTS , ... 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun #define EXFUN(name, proto) name proto 99*4882a593Smuzhiyun #define DEFUN(name, arglist, args) name(args) 100*4882a593Smuzhiyun #define DEFUN_VOID(name) name(void) 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun #define PROTO(type, name, arglist) type name arglist 103*4882a593Smuzhiyun #define PARAMS(paramlist) paramlist 104*4882a593Smuzhiyun #define ANSI_PROTOTYPES 1 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun #else /* Not ANSI C. */ 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun #define PTR char * 109*4882a593Smuzhiyun #define PTRCONST PTR 110*4882a593Smuzhiyun #define LONG_DOUBLE double 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun #define AND ; 113*4882a593Smuzhiyun #define NOARGS 114*4882a593Smuzhiyun #define CONST 115*4882a593Smuzhiyun #ifndef const /* some systems define it in header files for non-ansi mode */ 116*4882a593Smuzhiyun #define const 117*4882a593Smuzhiyun #endif 118*4882a593Smuzhiyun #define VOLATILE 119*4882a593Smuzhiyun #define SIGNED 120*4882a593Smuzhiyun #define DOTS 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun #define EXFUN(name, proto) name() 123*4882a593Smuzhiyun #define DEFUN(name, arglist, args) name arglist args; 124*4882a593Smuzhiyun #define DEFUN_VOID(name) name() 125*4882a593Smuzhiyun #define PROTO(type, name, arglist) type name () 126*4882a593Smuzhiyun #define PARAMS(paramlist) () 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun #endif /* ANSI C. */ 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun #endif /* ansidecl.h */ 131