Commit | Line | Data |
---|---|---|
d8875586 MBT |
1 | ?RCS: $Id: prototype.U 1 2006-08-24 12:32:52Z rmanfredi $ |
2 | ?RCS: | |
3 | ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi | |
4 | ?RCS: | |
5 | ?RCS: You may redistribute only under the terms of the Artistic Licence, | |
6 | ?RCS: as specified in the README file that comes with the distribution. | |
7 | ?RCS: You may reuse parts of this distribution only within the terms of | |
8 | ?RCS: that same Artistic Licence; a copy of which may be found at the root | |
9 | ?RCS: of the source tree for dist 4.0. | |
10 | ?RCS: | |
11 | ?RCS: $Log: prototype.U,v $ | |
12 | ?RCS: Revision 3.0.1.3 1994/05/06 15:11:49 ram | |
13 | ?RCS: patch23: ensure cc flags used when looking for prototype support | |
14 | ?RCS: | |
15 | ?RCS: Revision 3.0.1.2 1994/01/24 14:15:36 ram | |
16 | ?RCS: patch16: prototype handling macros now appear only when needed | |
17 | ?RCS: | |
18 | ?RCS: Revision 3.0.1.1 1993/08/25 14:03:12 ram | |
19 | ?RCS: patch6: defines were referring to non-existent VOID symbol | |
20 | ?RCS: | |
21 | ?RCS: Revision 3.0 1993/08/18 12:09:36 ram | |
22 | ?RCS: Baseline for dist 3.0 netwide release. | |
23 | ?RCS: | |
24 | ?MAKE:prototype: Myread Oldconfig cat +cc +ccflags rm Setvar | |
25 | ?MAKE: -pick add $@ %< | |
26 | ?S:prototype: | |
27 | ?S: This variable holds the eventual value of CAN_PROTOTYPE, which | |
28 | ?S: indicates the C compiler can handle funciton prototypes. | |
29 | ?S:. | |
30 | ?C:CAN_PROTOTYPE ~ %<: | |
31 | ?C: If defined, this macro indicates that the C compiler can handle | |
32 | ?C: function prototypes. | |
33 | ?C:. | |
34 | ?C:DOTS: | |
35 | ?C: This macro is used to specify the ... in function prototypes which | |
36 | ?C: have arbitrary additional arguments. | |
37 | ?C:. | |
38 | ?C:NXT_ARG: | |
39 | ?C: This macro is used to separate arguments in the declared argument list. | |
40 | ?C:. | |
41 | ?C:P_FUNC: | |
42 | ?C: This macro is used to declare "private" (static) functions. | |
43 | ?C: It takes three arguments: the function type and name, a parenthesized | |
44 | ?C: traditional (comma separated) argument list, and the declared argument | |
45 | ?C: list (in which arguments are separated with NXT_ARG, and additional | |
46 | ?C: arbitrary arguments are specified with DOTS). For example: | |
47 | ?C: | |
48 | ?C: P_FUNC(int foo, (bar, baz), int bar NXT_ARG char *baz[]) | |
49 | ?C:. | |
50 | ?C:P_FUNC_VOID: | |
51 | ?C: This macro is used to declare "private" (static) functions that have | |
52 | ?C: no arguments. The macro takes one argument: the function type and name. | |
53 | ?C: For example: | |
54 | ?C: | |
55 | ?C: P_FUNC_VOID(int subr) | |
56 | ?C:. | |
57 | ?C:V_FUNC: | |
58 | ?C: This macro is used to declare "public" (non-static) functions. | |
59 | ?C: It takes three arguments: the function type and name, a parenthesized | |
60 | ?C: traditional (comma separated) argument list, and the declared argument | |
61 | ?C: list (in which arguments are separated with NXT_ARG, and additional | |
62 | ?C: arbitrary arguments are specified with DOTS). For example: | |
63 | ?C: | |
64 | ?C: V_FUNC(int main, (argc, argv), int argc NXT_ARG char *argv[]) | |
65 | ?C:. | |
66 | ?C:V_FUNC_VOID: | |
67 | ?C: This macro is used to declare "public" (non-static) functions that have | |
68 | ?C: no arguments. The macro takes one argument: the function type and name. | |
69 | ?C: For example: | |
70 | ?C: | |
71 | ?C: V_FUNC_VOID(int fork) | |
72 | ?C:. | |
73 | ?C:_ (P): | |
74 | ?C: This macro is used to declare function parameters for folks who want | |
75 | ?C: to make declarations with prototypes using a different style than | |
76 | ?C: the above macros. Use double parentheses. For example: | |
77 | ?C: | |
78 | ?C: int main _((int argc, char *argv[])); | |
79 | ?C:. | |
80 | ?H:?%<:#$prototype CAN_PROTOTYPE /**/ | |
81 | ?H:?%<:#ifdef CAN_PROTOTYPE | |
82 | ?H:?NXT_ARG:#define NXT_ARG , | |
83 | ?H:?DOTS:#define DOTS , ... | |
84 | ?H:?V_FUNC:#define V_FUNC(name, arglist, args)name(args) | |
85 | ?H:?P_FUNC:#define P_FUNC(name, arglist, args)static name(args) | |
86 | ?H:?V_FUNC_VOID:#define V_FUNC_VOID(name)name(void) | |
87 | ?H:?P_FUNC_VOID:#define P_FUNC_VOID(name)static name(void) | |
88 | ?H:?_:#define _(args) args | |
89 | ?H:?%<:#else | |
90 | ?H:?NXT_ARG:#define NXT_ARG ; | |
91 | ?H:?DOTS:#define DOTS | |
92 | ?H:?V_FUNC:#define V_FUNC(name, arglist, args)name arglist args; | |
93 | ?H:?P_FUNC:#define P_FUNC(name, arglist, args)static name arglist args; | |
94 | ?H:?V_FUNC_VOID:#define V_FUNC_VOID(name)name() | |
95 | ?H:?P_FUNC_VOID:#define P_FUNC_VOID(name)static name() | |
96 | ?H:?_:#define _(args) () | |
97 | ?H:?%<:#endif | |
98 | ?H:. | |
99 | ?W:%<:NXT_ARG DOTS V_FUNC P_FUNC V_FUNC_VOID P_FUNC_VOID _ | |
100 | ?LINT:set prototype | |
101 | : Cruising for prototypes | |
102 | echo " " | |
103 | echo "Checking out function prototypes..." >&4 | |
104 | $cat >prototype.c <<'EOCP' | |
105 | int main(int argc, char *argv[]) { | |
106 | exit(0);} | |
107 | EOCP | |
108 | if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then | |
109 | echo "Your C compiler appears to support function prototypes." | |
110 | val="$define" | |
111 | else | |
112 | echo "Your C compiler doesn't seem to understand function prototypes." | |
113 | val="$undef" | |
114 | fi | |
115 | set prototype | |
116 | eval $setvar | |
117 | $rm -f prototype* | |
118 |