From: Alona on
Hi All,

Are there predefined macros to identify Solaris version at runtime?
We need to differentiate betweeb Solaris8 and later versions.

Thanks,
Alona
From: Doug McIntyre on
Alona <arossen(a)rogers.com> writes:
>Are there predefined macros to identify Solaris version at runtime?
>We need to differentiate betweeb Solaris8 and later versions.

Macros are usually used when compiling?

If you want to programatically determine what version of the OS
is running, use sysinfo().

#include <sys/systeminfo.h>
#include <stdio.h>

int main(int argc, char **argv, char **envp)
{
char version[100];
sysinfo(SI_RELEASE,&version,sizeof(version));
printf("System Version is: %s\n",&version);
}

Output:
System Version is: 5.10

You can get the kernel patch rev, architecture, 64bit support or not, etc.

Another way is to use uname, which will get some of the same info.


 | 
Pages: 1
Prev: Library version
Next: USB devices with Solaris 8