Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 04 Jun 2014 10:12:06 +0800
From:      Julian Elischer <julian@freebsd.org>
To:        Benjamin Kaduk <bjk@freebsd.org>, Sreenivasa Honnur <shonnur@chelsio.com>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: How to Check kernel version in code?
Message-ID:  <538E8076.1060809@freebsd.org>
In-Reply-To: <alpine.GSO.1.10.1406031142440.25244@multics.mit.edu>
References:  <538B61EC.9000403@mu.org> <5B82C892-12A4-4251-B3D2-A6D3EAAF90F9@dataix.net> <538B6FCC.9090301@mu.org> <B007D0DE-EFC1-49D8-9E6A-F4A24B66DB8C@dataix.net> <538B761C.7060300@mu.org> <50E51CBE-7F7B-4093-86A5-320ACE81072E@dataix.net> <538B7937.2030104@mu.org> <098847BE-04B5-4E6F-98B8-87B5C7055C69@mail.turbofuzz.com> <538B8494.3040701@mu.org> <7977A65A-5ABE-49DD-8E76-074B54943D64@mail.turbofuzz.com> <538BDDF5.708@mu.org> <409ccb2cf1dc027bdf6ff7ccbda08723.authenticated@ultimatedns.net> <538C8DDF.3030602@mu.org> <538D4C93.1060808@freebsd.org> <B9DED949-63C2-452B-A2F5-A0D00065A64A@mu.org> <538D50B3.300@freebsd.org> <F2BBBB6E0068844991318A316F34795C38B8D8@nice.asicdesigners.com> <alpine.GSO.1.10.1406031142440.25244@multics.mit.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 6/3/14, 11:43 PM, Benjamin Kaduk wrote:
> On Tue, 3 Jun 2014, Sreenivasa Honnur wrote:
>
>> I want to enable some code based on FBSD kernel versions like below:
>>
>> #ifdef FreeBSD_VERSION_10
>>
>> #endif
>>
>> #ifdef FreeBSD_VERSION_9.2
>>
>> #endif
>>
>>
>> How can I do achieve this?
>
> __FreeBSD_version is defined in sys/param.h, and is incremented for 
> major version changes as well as other events of note.
>
> Increments are tabulated at 
> http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html

Realise though that this is hte version of the environment where the 
BUILD is done, not the environment where the program is running. The 
use of #if suggests this is what you want, but there are also dynamic 
ways to test.


>
> -Ben Kaduk
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to 
> "freebsd-hackers-unsubscribe@freebsd.org"
>
>




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?538E8076.1060809>