List Info

Thread: ifdefs for detecting Solaris




ifdefs for detecting Solaris
country flaguser name
United States
2007-09-13 14:48:25
The JDS Code Review Process at http://www.opensolaris.org/os/project/jds/documen
ts/code_review recommends using #if defined(sun)
&& defined(__SVR4) to detect Solaris. However, the
Sun Studio C Compiler doesn't define sun if the -Xc option
(strict ISO C) is used. See h
ttp://docs.sun.com/app/docs/doc/819-5265/6n7c29clo

Also gcc doesn't define sun if the -ansi option is
specified.
% /usr/sfw/bin/gcc -ansi -c -E -dM file.c | egrep -i
'sun|svr4' 
#define __SVR4 1
#define __sun 1
#define __sun__ 1
#define __svr4__ 1

A better check for Solaris would be

#if defined(__sun) && defined(__SVR4)

Chris
 
 
This message posted from opensolaris.org
_______________________________________________
desktop-discuss mailing list
desktop-discussopensolaris.org

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )