xref: /freebsd/share/examples/FreeBSD_version/FreeBSD_version.c (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
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 #include <stdio.h>
9 #include <unistd.h>
10 
11 int
12 main(void) {
13 	printf("Compilation release date: %d\n", __FreeBSD_version);
14 #if __FreeBSD_version >= 199408
15 	printf("Execution environment release date: %d\n", getosreldate());
16 #else
17 	printf("Execution environment release date: can't tell\n");
18 #endif
19 	return (0);
20 }
21