Detect SunPro compiler version with its id

Decode hex digits from __SUNPRO_C and __SUNPRO_CC to compute the version
number components.  Note that the constant encodes decimal digits as hex
digits (never larger than 9).  We represent them as decimal after
extraction.  See documentation at

  http://predef.sourceforge.net/precomp.html

Although the documented version number format is

  0xVRP where V = Version, R = Revision, P = Patch

it holds only though SunPro C/C++ version 5.9.  Later versions have
a two-digit revision (minor) number so their format is 0xVRRP.
This commit is contained in:
Brad King 2011-12-07 09:22:11 -05:00
parent c198730b45
commit 3dd9fa9d6a
2 changed files with 18 additions and 0 deletions

View File

@ -33,6 +33,15 @@
#elif defined(__SUNPRO_C) #elif defined(__SUNPRO_C)
# define COMPILER_ID "SunPro" # define COMPILER_ID "SunPro"
# if __SUNPRO_C >= 0x5100
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
# else
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
# endif
#elif defined(__HP_cc) #elif defined(__HP_cc)
# define COMPILER_ID "HP" # define COMPILER_ID "HP"

View File

@ -35,6 +35,15 @@
#elif defined(__SUNPRO_CC) #elif defined(__SUNPRO_CC)
# define COMPILER_ID "SunPro" # define COMPILER_ID "SunPro"
# if __SUNPRO_CC >= 0x5100
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
# else
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
# endif
#elif defined(__HP_aCC) #elif defined(__HP_aCC)
# define COMPILER_ID "HP" # define COMPILER_ID "HP"