#!/bin/sh # sizeof -- print size of standard C types # Author: Noah Friedman # Created: 2007-03-23 # Public domain. # $Id: sizeof,v 1.4 2019/03/21 23:58:07 friedman Exp $ # Commentary: # Code: cd ${TMPDIR-/tmp} || exit 1 file="sizeof$$" trap 'rm -f $file $file.[co]' 0 1 2 3 15 type=$1 shift cat > $file.c <<- __EOF__ #include #include `for h in "$@"; do case $h in '#'* ) echo "$h" ;; * ) echo " #include <$h>" ;; esac done` int main () { printf ("%ld\n", sizeof ($type)); return 0; } __EOF__ ${CC-cc} $CFLAGS $file.c -o $file && ./$file # eof