?RCS: $Id: voidflags.U,v 3.0.1.2 1997/02/28 16:27:58 ram Exp $ ?RCS: ?RCS: Copyright (c) 1991-1993, Raphael Manfredi ?RCS: ?RCS: You may redistribute only under the terms of the Artistic Licence, ?RCS: as specified in the README file that comes with the distribution. ?RCS: You may reuse parts of this distribution only within the terms of ?RCS: that same Artistic Licence; a copy of which may be found at the root ?RCS: of the source tree for dist 3.0. ?RCS: ?RCS: $Log: voidflags.U,v $ ?RCS: Revision 3.0.1.2 1997/02/28 16:27:58 ram ?RCS: patch61: don't prompt them if the void support is high enough for us ?RCS: ?RCS: Revision 3.0.1.1 1995/01/11 15:37:44 ram ?RCS: patch45: cosmetic change to avoid spurious blank lines when using -s ?RCS: ?RCS: Revision 3.0 1993/08/18 12:10:01 ram ?RCS: Baseline for dist 3.0 netwide release. ?RCS: ?MAKE:voidflags defvoidused: cat rm_try contains +cc +ccflags package \ Oldconfig Myread i_stdlib ?MAKE: -pick add $@ %< ?S:voidflags: ?S: This variable contains the eventual value of the VOIDFLAGS symbol, ?S: which indicates how much support of the void type is given by this ?S: compiler. See VOIDFLAGS for more info. ?S:. ?S:defvoidused: ?S: This variable contains the default value of the VOIDUSED symbol (15). ?S:. ?X: Exceptionally, we have to explicitely alias the symbol name for ?X: config_h.SH, otherwise the comment would not appear. ?C:VOIDFLAGS ~ %<: ?C: This symbol indicates how much support of the void type is given by this ?C: compiler. What various bits mean: ?C: ?C: 1 = supports declaration of void ?C: 2 = supports arrays of pointers to functions returning void ?C: 4 = supports comparisons between pointers to void functions and ?C: addresses of void functions ?C: 8 = suports declaration of generic void pointers ?C: ?C: The package designer should define VOIDUSED to indicate the requirements ?C: of the package. This can be done either by #defining VOIDUSED before ?C: including config.h, or by defining defvoidused in Myinit.U. If the ?C: latter approach is taken, only those flags will be tested. If the ?C: level of void support necessary is not present, defines void to int. ?C:. ?H:?%<:#ifndef VOIDUSED ?H:?%<:#define VOIDUSED $defvoidused ?H:?%<:#endif ?H:?%<:#define VOIDFLAGS $voidflags ?H:?%<:#if (VOIDFLAGS & VOIDUSED) != VOIDUSED ?H:?%<:#define void int /* is void to be avoided? */ ?H:?%<:#define M_VOID /* Xenix strikes again */ ?H:?%<:#endif ?H:. ?W:%<:void ?INIT:: full support for void wanted by default ?INIT:defvoidused=15 ?INIT: ?LINT:known void M_VOID VOIDUSED : check for void type echo " " echo "Checking to see how well your C compiler groks the void type..." >&4 case "$voidflags" in '') $cat >try.c < #endif #if TRY & 1 void sub() { #else sub() { #endif extern void moo(); /* function returning void */ void (*goo)(); /* ptr to func returning void */ #if TRY & 8 void *hue; /* generic ptr */ #endif #if TRY & 2 void (*foo[10])(); #endif #if TRY & 4 if(goo == moo) { exit(0); } #endif exit(0); } int main() { sub(); } EOCP ?X: This unit used to use cc -S in those tests to try to speed up things, but ?X: unfortunately, AIX 3.2 does not support this option. if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then voidflags=$defvoidused echo "Good. It appears to support void to the level $package wants.">&4 if $contains warning .out >/dev/null 2>&1; then echo "However, you might get some warnings that look like this:" $cat .out fi else echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then echo "It supports 1..." if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then echo "It also supports 2..." if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then voidflags=7 echo "And it supports 4 but not 8 definitely." else echo "It doesn't support 4..." if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then voidflags=11 echo "But it supports 8." else voidflags=3 echo "Neither does it support 8." fi fi else echo "It does not support 2..." if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then voidflags=13 echo "But it supports 4 and 8." else if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then voidflags=5 echo "And it supports 4 but has not heard about 8." else echo "However it supports 8 but not 4." fi fi fi else echo "There is no support at all for void." voidflags=0 fi fi esac ?X: Only prompt user if support does not match the level we want case "$voidflags" in "$defvoidused") ;; *) $cat >&4 <<'EOM' Support flag bits are: 1: basic void declarations. 2: arrays of pointers to functions returning void. 4: operations between pointers to and addresses of void functions. 8: generic void pointers. EOM dflt="$voidflags"; rp="Your void support flags add up to what?" . ./myread voidflags="$ans" ;; esac $rm_try