This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[UTIL] Perl system does not default to $_
[metaconfig.git] / dist / U / charsize.U
1 ?RCS: $Id$
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 License,
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 License; 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: charsize.U,v $
12 ?RCS: Revision 3.0.1.1  1994/10/29  16:07:13  ram
13 ?RCS: patch36: added ?F: line for metalint file checking
14 ?RCS:
15 ?RCS: Revision 3.0  1993/08/18  12:05:34  ram
16 ?RCS: Baseline for dist 3.0 netwide release.
17 ?RCS:
18 ?MAKE:charsize: Assert Myread cat rm +cc +ccflags echo n c
19 ?MAKE:  -pick add $@ %<
20 ?S:charsize:
21 ?S:     This variable contains the value of the CHARSIZE symbol, which
22 ?S:     indicates to the C program how many bytes there are in a character.
23 ?S:.
24 ?C:CHARSIZE:
25 ?C:     This symbol contains the size of a char, so that the C preprocessor
26 ?C:     can make decisions based on it.
27 ?C:.
28 ?H:#define CHARSIZE $charsize
29 ?H:.
30 ?T:size s
31 : check for length of character
32 echo " "
33 $echo $n "Checking to see how big your characters are...$c" >&4
34 for size in 1 2 4 8 error; do
35         $cat >try.c <<EOCP
36 #include "static_assert.h"
37 char foo;
38 int main()
39 {
40         STATIC_ASSERT($size == sizeof(foo));
41         return 0;
42 }
43 EOCP
44         if $cc -c $ccflags try.c >/dev/null 2>&1; then break; fi
45 done
46 case "$size" in
47 error)
48         echo " cannot compute it." >&4
49         dflt=1
50         rp="What is the size of a character (in bytes)?"
51         . ./myread
52         charsize="$ans"
53         ;;
54 *)
55         case "$size" in
56         1) s='';;
57         *) s='s';;
58         esac
59         echo " $size byte$s." >&4
60         charsize=$size
61         ;;
62 esac
63 $rm -f try.*
64