Diffstat (limited to 'mcon/U/charsize.U')
1 files changed, 29 insertions, 23 deletions
diff --git a/mcon/U/charsize.U b/mcon/U/charsize.U
index 388e5c1..7135e5b 100644
@@ -1,11 +1,11 @@
-?RCS: $Id: charsize.U 1 2006-08-24 12:32:52Z rmanfredi $
+?RCS: $Id: charsize.U 167 2013-05-08 17:58:00Z rmanfredi $
?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
-?RCS: You may redistribute only under the terms of the Artistic Licence,
+?RCS: You may redistribute only under the terms of the Artistic License,
?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: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS: $Log: charsize.U,v $
@@ -15,7 +15,7 @@
?RCS: Revision 3.0 1993/08/18 12:05:34 ram
?RCS: Baseline for dist 3.0 netwide release.
-?MAKE:charsize: cat rm Myread +cc +ccflags
+?MAKE:charsize: Assert Myread cat rm +cc +ccflags echo n c
?MAKE: -pick add $@ %<
?S: This variable contains the value of the CHARSIZE symbol, which
@@ -25,34 +25,40 @@
?C: This symbol contains the size of a char, so that the C preprocessor
?C: can make decisions based on it.
-?H:#define CHARSIZE $charsize /**/
+?H:#define CHARSIZE $charsize
: check for length of character
echo " "
-case "$charsize" in
- echo "Checking to see how big your characters are..." >&4
- $cat >try.c <<'EOCP'
+$echo $n "Checking to see how big your characters are...$c" >&4
+for size in 1 2 4 8 error; do
+ $cat >try.c <<EOCP
- printf("%d\n", sizeof(char));
+ STATIC_ASSERT($size == sizeof(foo));
+ return 0;
- if $cc $ccflags -o try try.c >/dev/null 2>&1 ; then
- echo "(I can't seem to compile the test program. Guessing...)"
+ if $cc -c $ccflags try.c >/dev/null 2>&1; then break; fi
+case "$size" in
+ echo " cannot compute it." >&4
+ rp="What is the size of a character (in bytes)?"
+ . ./myread
+ case "$size" in
+ 1) s='';;
+ *) s='s';;
+ echo " $size byte$s." >&4
-rp="What is the size of a character (in bytes)?"
-$rm -f try.c try
+$rm -f try.*