xref: /freebsd/share/examples/FreeBSD_version/FreeBSD_version.c (revision 1669d8afc64812c8d2d1d147ae1fd42ff441e1b1)
1 #if __FreeBSD__ == 0		/* 1.0 did not define __FreeBSD__ */
2 #define __FreeBSD_version 199401
3 #elif __FreeBSD__ == 1		/* 1.1 defined it to be 1 */
4 #define __FreeBSD_version 199405
5 #else				/* 2.0 and higher define it to be 2 */
6 #include <osreldate.h>		/* and this works */
7 #endif
8 
9 int main(void) {
10   extern int getosreldate(void);
11   printf("Compilation release date: %d\n", __FreeBSD_version);
12 #if __FreeBSD_version >= 199408
13   printf("Execution environment release date: %d\n", getosreldate());
14 #else
15   printf("Execution environment release date: can't tell\n");
16 #endif
17 }
18