Alan,

The compiler default of -xc99=all,no_lib
is C99 language features, but C90 library behavior.

-xc99=all gets both C99 language and library features, and results
in setting __STDC_VERSION__ to 199901L.  C99 library support is
only available on Solaris 10 and later.

If all you need are the C99 language features (and I believe that is so),
the Sun Studio compiler predefines __C99FEATURES__ when these are
available, such as with the default -xc99=all,no_lib.

We don't document __C99FEATURES__ as we originally intended it for
Solaris header file use.  But there is really no reason to limit it
to any such use, we should document it.

__C99FEATUES__ was introduced with Sun Studio 10, the first compiler
to provide full C99 support.

Sorry, I have no list chronicling when we added each C99 language feature
to the Sun Studio C compilers.

Douglas

Chris Quenelle wrote:
> 
> 
> -------- Original Message --------
> Subject: [tools-compilers] #ifdef checks for inline, __func__,    etc in 
> Sun Studio?
> Date: Tue, 10 Jun 2008 15:40:50 -0700
> From: Alan Coopersmith <Alan.Coopersmith at Sun.COM>
> To: tools-compilers at opensolaris.org
> 
> I'm working on improving Sun Studio support in one of the open-source
> packages we ship in OpenSolaris & Solaris.
> 
> Right now it has #ifdef's such as:
> 
> #if defined(__GNUC__)
> #  define INLINE __inline__
> #elif defined(__MSC__)
> #  define INLINE __inline
> #elif defined(_MSC_VER)
> #  define INLINE __inline
> #elif defined(__ICL)
> #  define INLINE __inline
> #elif defined(__INTEL_COMPILER)
> #  define INLINE inline
> #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
> #  define INLINE __inline
> #else
> #  define INLINE
> #endif
> 
> #if defined(__VMS)
> # define __FUNCTION__ "VMS$NL:"
> #elif __STDC_VERSION__ < 199901L
> # if ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
>      (!defined(_MSC_VER) || _MSC_VER < 1300)
> #  define __FUNCTION__ "<unknown>"
> # endif
> #endif
> 
> What are the right checks for enabling inline & __func__ in Sun Studio?
> I would have thought checking for __STDC_VERSION__ >= 199901L would be
> enough, but it appears that the default value of __STDC_VERSION__ in
> Studio 12 is only 199901L, despite the documentation saying that
> -xc99=all,no_lib is default (and giving no information I could see
> on what that means for __STDC_VERSION__).
> 
> Do I just need to add something like:
> 
> #elif defined(__SUNPRO_C) && (__SUNPRO_C > 0x0550)
> 
> and if so is there any list of what versions support what features
> without having to manually compare the last 10 versions worth of compiler
> docs on docs.sun.com?
> 

Reply via email to