Question about SunOS version, how to include in C source

Sorry if here is the wrong place to put this question, but for college we develop small programs in C using Solaris. Most of time is OK for us not to document nothing, until now.

Every time program is executed must print OS name.

Does Solaris has some predefined macros which I can include in my source.

For example

printf("OS: %s \n", __os__);

with result

SunOS 5.11

I found __'System'_'Version' , but it doesn' t work

use uname it will give you the OS details along with other details

$ uname -a
CYGWIN_NT-5.1 venkat-LXP 1.7.5(0.225/5/3) 2010-04-12 19:07 i686 Cygwin

This will print OS information on which is run. I need to incorporate that using macro.

This code:

#include <sys/utsname.h>

main()
{
   struct utsname name;
   uname(&name);
   printf("%s %s\n",name.sysname,name.release);
}

will output:

SunOS 5.11
1 Like