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