Subject: Re: Checking for NetBSD version
To: Alan Barrett <apb@cequrux.com>
From: Frederick Bruckman <fredb@immanent.net>
List: current-users
Date: 11/17/2003 02:31:25
On Mon, 17 Nov 2003, Alan Barrett wrote:

> On Mon, 17 Nov 2003, martti.kuparinen@piuha.net wrote:
> > What is "the correct way" of checking NetBSD version (1.x vs -current) in
> > source code (with preprocessor)? In other words, how should I rewrite
> > the "if 1" line in the following code fragment?
>
> #include <sys/param.h>
> #if defined(__NetBSD_Version__) && (__NetBSD_Version__ < 106110000)
> 	/* NetBSD < 1.6K does not have separate read/write statistics. */

I seem to recall that the change occurred *in* 1.6K. There's no
backwards compatibility, so someone's going to lose no matter where
you draw the line.

BTW, you can simplify by turning that around:

#if __NetBSD_Version__ >= 106110000
/* separate read/write statistics */
#else
/* ... */
#endif

as __NetBSD_Version__ will compare numerically as if it were "0" for
non-NetBSD or older NetBSD systems (for any ANSI compiler).

Frederick