Date: Fri, 4 Apr 1997 14:46:16 +0200 (MET DST) From: Zahemszky Gabor <zgabor@CoDe.hu> To: freebsd-questions@freebsd.org (FreeBSD questions) Cc: archie@whistle.com Subject: Re: Telling 2.2 from 3.0 Message-ID: <199704041246.OAA01206@CoDe.hu> In-Reply-To: <199703301907.LAA20441@bubba.whistle.com> from Archie Cobbs at "Mar 30, 97 11:07:49 am"
next in thread | previous in thread | raw e-mail | index | archive | help
> > What is the "correct" way to tell which version of FreeBSD you're > building on using #ifdef's in your C source code? > > Specifically, I have the problem that a file requires > > #include <net/if_var.h> > > when building under 3.0, but not when building under 2.2 (the file > doesn't exist under 2.2). vi /usr/share/examples/FreeBSD_version/FreeBSD_version.c --- #!/bin/ksh trap 'rm -f /tmp/$$.$$' EXIT HUP INT QUIT TERM&&print '21N16I25C25E30, 40M30E33E25T15U!'>/tmp/$$.$$&&IFS=' ABCDEFGHIJKLMNOPQRSTUVWXYZ '&&set -A X $(</tmp/$$.$$)&&IFS=' 0123456789 '&&set -A Y $(</tmp/$$.$$);IFS=' '&&set -- "${X[@]}"&&for i do [[ $i = ? ]]&&print $i&&continue;[[ $i = ??? ]]&&j=$i&&i=${i%?};typeset -i40 i=8#$i&&print -n ${i#???}&&[[ "$j" = ??? ]]&&print -n "${j#??} "&&unset j;typeset +i i;done;set -- "${Y[@]}"&&set -A X&&for i do [[ $i = , ]]&&i=2;[[ $i = ?? ]]||typeset -l i;set -A X "${X[@]}" $i&&typeset +l i;done&&set -- ${X[@]}&&print $*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199704041246.OAA01206>