How to get system version ?

How is it possible to get system version at runtime ?
There are several way to get version information:
- specific to Cocoa applications, there is the
NSAppKitVersionNumber global variable (see the latest Panther technote);
- the old-days
Gestalt call is still supported in Carbon;
SInt32 vers;
Gestalt(gestaltSystemVersion,&vers);
- the Unix way with sysctlwith a mib of {CTL_KERN, KERN_OSRELEASE}. See man 3 sysctl. Note that this functionality is also available at command line: man 1 sysctl.