standards, ANSI, C, C++, ISO, POSIX, POSIX.1, POSIX.2, SUS, SUSv2, SUSv3, SUSv4, SVID, SVID3, XNS, XNS4, XNS5, XPG, XPG3, XPG4, XPG4v2, XPG5, XPG6, XPG7 - 标准和规范受 Oracle Solaris 11.4 支持
Oracle Solaris 11.4 符合 The Open Group 的 UNIX V7 产品标准,这意味着它支持 IEEE Std 1003.1-2008(通常称为 POSIX.1-2008)、UNIX V7、XPG7 或 SUSv4(Single UNIX Specification, Version 4,单一 UNIX 规范版本 4)。请注意,POSIX.1-2008 同时涵盖 IEEE Std 1003.1-2008 和 The Open Group Technical Standard Base Specifications, Version 7。请注意,SUSv4 结合了 IEEE Std 1003.1-2008 和 ISO/IEC 9945:2009 (Portable Operating System Interface (POSIX) Base Specifications, Issue 7)。编写新代码时应使用 UNIX V7 标准。有关最初符合特定标准的 SunOS 或 Oracle Solaris 发行版以及运行在先前版本的 Oracle Solaris 上编译的代码时的要求的历史信息,请参见此手册页的最后一节。
When using the Oracle Developer Studio 12.5 or 12.6 C compiler or the latest version of GCC or LLVM/Clang found in Oracle Solaris 11.4, Oracle Solaris 11.4 supports:
The ANSI X3.159-1989 Programming Language - C (C89) and ISO/IEC 9899:1990 Programming Language - C (C90) interfaces
ISO/IEC 9899:1990 Amendment 1:1995: C Integrity (C95)
ISO/IEC 9899:1999 Programming Languages - C (C99)
INCITS/ISO/IEC 9899:2011 Programming Languages - C (C11)
See the documentation for each compiler to learn how to use the –std option to control which standard is followed when compiling C code.
If a C++ compiler such as Oracle Developer Studio, Oracle Solaris Studio, g++, or clang++ is installed, refer to its documentation for a discussion of which C++ standards are supported.
对于联网,XNS4 规范只有在 ILP32(32 位)环境中使用才是安全的,不应该用于 LP64(64 位)应用程序环境。对于 LP64(64 位)应用程序环境,应使用 XNS5 或 SUSv3,因为它们具有可在 ILP32 和 LP64 环境中移植的干净的 LP64 接口。Oracle Solaris 11.4 支持 ILP32 和 LP64 两种环境。Oracle Solaris 的未来发行版可能只支持 LP64 环境。
缺省的 Oracle Solaris 安装可能需要额外的步骤,以与 SUSv4 完全兼容。
PackagesThe XPG7 Conformance group package and Oracle Developer Studio must be installed.
|
通常,ZFS(缺省根文件系统)与 SUSv4 兼容。但是,在以下边界情况下,ZFS 不满足符合性要求:
Updating ZFS file system capacity statistics.
在几乎完整的文件系统中修改或删除现有数据。
要求严格符合 SUSv4 的应用程序必须在 UFS 上操作,并需要在 ZFS zvol 设备上设置 UFS 文件系统。
如果 POSIX.1-2008 要求的行为与历史 Solaris 实用程序行为冲突,则该实用程序的原始 Solaris 版本保持不变,并在 /usr/xpg7/bin 中提供该实用程序的符合标准的版本。有关早期标准版本的历史详细信息,请参见本手册页末尾。
如果应用程序要使用符合 POSIX.1-2008 标准的实用程序,则必须设置 PATH(sh(1) 或 ksh(1))或者 path (csh(1)) 环境变量,以指定顺序指定下列目录来获取相应的实用程序。有关早期版本中指定目录的历史详细信息,请参见本手册页末尾。
/usr/xpg7/bin
/usr/xpg6/bin
/usr/xpg4/bin
/usr/bin
包含编译器的二进制文件的目录
包含应用程序所需的二进制文件的其他目录
设置了 PATH/path 变量后,可以使用 getconf 命令确认设置。
When an application uses the execlp() function, execvp() function or execvpe() function to execute a shell file, or uses the system(3C) function, the shell used to interpret the shell file depends on the standard to which the calling program conforms.有关更多信息,请参见 exec(2) 手册页。
|
功能测试宏供应用程序用来指示用户需要的 C 标准指定的那些功能之外的其他功能集。如果应用程序仅使用特定标准(如 POSIX 或 SUSv4)定义的接口和头,则仅需要定义该标准指定的相应功能测试宏。如果应用程序要使用该标准未定义的接口和头,则除了定义相应的标准功能测试宏之外,还必须定义 __EXTENSIONS__。通过定义 __EXTENSIONS__,应用程序便可以访问与指定的标准不冲突的所有接口和头。应用程序必须在编译命令行或应用程序源文件中定义 __EXTENSIONS__。
POSIX.1-2008要符合 POSIX.1-2008 的应用程序必须在加入任何头之前定义功能测试宏 _POSIX_C_SOURCE=200809L。应用程序编写者必须在标准中查找其他可查询的宏,以确定实现是否支持所需的选项。
SUSv4要构建或编译符合 SUSv4 规范的应用程序,该应用程序必须定义 _XOPEN_SOURCE=700。如果应用程序同时需要 SUS 和 POSIX 功能,则不需要设置 POSIX.1-2008 功能测试宏。
1989 ANSI C、1990 ISO C、1999 ISO C、2011 ISO C无需定义功能测试宏来指示应用程序符合 C 标准。
ANSI/ISO C++ANSI/ISO C++ 未定义任何功能测试宏。如果编译器根据编译器缺省值和命令行选项预定义的标准 C++ 声明宏 __cplusplus 设置为 199711 或更大值,则编译器会以符合标准的模式运行,并指示符合 C++ 标准。有关此宏可以具有的值和受支持的 C++ 标准版本的说明,请参阅 C++ 编译器文档。
未针对 POSIX 或 SUSv4 定义 C++ 绑定,因此指定功能测试宏(如 _POSIX_SOURCE、_POSIX_C_SOURCE 和 _XOPEN_SOURCE)会由于与 C++ 标准和这些规范的要求冲突而导致编译错误。
The Oracle Developer Studio 12.5 and 12.6 C Compilers provide the INCITS/ISO/IEC 9899:2011 (C11) standard-conforming compilation system by default.They also provide the ISO/IEC 9899:1999 (C99) standard-conforming compilation system.
If the compiler supports the redefine_extname pragma feature, the Oracle Developer Studio C Compiler and C++ Compiler define the macro __PRAGMA_REDEFINE_EXTNAME to indicate that they support this feature.如果不满足前面的条件,则标准头会使用 #pragma redefine_extname 指令将函数名称正确映射到库入口点名称。此映射完全支持 ISO C、POSIX 和 X/Open 名称空间保留项。
When using the Oracle Developer Studio 12.5 or 12.6 C Compiler, applications conforming to POSIX.1-2008 should be compiled using the utilities and flags indicated in the following table:
|
Oracle Solaris 曾支持 IEEE Std 1003.1 和 IEEE Std 1003.2(通常分别称为 POSIX.1 和 POSIX.2)。下表列出了这些标准的每个版本及其简要说明,以及最先遵从这些标准的 SunOS 或 Solaris 发行版。
|
Oracle Solaris also has a history of supporting the X/Open Common Applications Environment (CAE) Portability Guide Issue 3 (XPG3) and Issue 4 (XPG4); Single UNIX Specification (SUS, also known as XPG4v2); Single UNIX Specification, Version 2 (SUSv2); Single UNIX Specification, Version 3 (SUSv3); and Single UNIX Specification, Version 4 (SUSv4).XPG4 和 SUS 均包括 Networking Services Issue 4 (XNS4)。SUSv2 包括 Networking Services Issue 5 (XNS5)。
下表列出了每个 X/Open 规范及其简要说明,以及最先遵从这些标准的 SunOS 或 Solaris 发行版。
|
Solaris 发行版 7 到 Oracle Solaris 11.4 支持 ILP32 和 LP64 两种环境。Oracle Solaris 的未来发行版可能只支持 LP64 环境。
Solaris 发行版 2.0 到 Oracle Solaris 11.4 支持 System V 接口定义第 3 版的卷 1 至卷 4 (SVID3) 指定的接口。请注意,由于此规范的开发者 (UNIX Systems Laboratories) 已不再运营并且此规范遵从 POSIX 和 X/Open CAE 规范,因此对符合此规范当前所要达到的要求有一些分歧。
Solaris 发行版 7 到 10 标为符合 The Open Group 的 UNIX 98 产品标准。Solaris 10 到 Oracle Solaris 11 标为符合 The Open Group 的 UNIX 03 产品标准。
如果 POSIX.2、POSIX.2a、XPG4、SUS 或 SUSv2 要求的行为与历史 Solaris 实用程序行为冲突,则该实用程序的原始 Solaris 版本保持不变,并在 /usr/xpg4/bin 中提供该实用程序的符合标准的版本。如果 POSIX.1-2001 或 SUSv3 要求的行为与历史 Solaris 实用程序行为冲突,则在 /usr/xpg4/bin 或 /usr/xpg6/bin 中提供符合标准的版本。如果 POSIX.1-2001 或 SUSv3 要求的行为与 POSIX.2、POSIX.2a、SUS 或 SUSv2 冲突,则在 /usr/xpg6/bin 中提供符合标准的版本。
如果应用程序要使用符合标准的实用程序,则必须设置 PATH(sh(1) 或 ksh(1))或者 path (csh(1)) 环境变量,以指定顺序指定下列目录来获取相应的实用程序:
/usr/bin
包含编译器的二进制文件的目录
包含应用程序所需的二进制文件的其他目录
/usr/xpg4/bin
/usr/bin
包含编译器的二进制文件的目录
包含应用程序所需的二进制文件的其他目录
/usr/xpg6/bin
/usr/xpg4/bin
/usr/bin
包含编译器的二进制文件的目录
包含应用程序所需的二进制文件的其他目录
When an application uses the execlp() function or execvp() function to execute a shell file, or uses the system(3C) function, the shell used to interpret the shell file depends on the standard to which the calling program conforms.有关更多信息,请参见 exec(2) 手册页。
|
如上所述,功能测试宏供应用程序用来指示用户需要的 C 标准指定的那些功能之外的其他功能集。The following sections outline historical information about POSIX versions prior to POSIX.1-2008, X/Open CAE prior to SUSv4, and SVID3.
POSIX下表列出了适用于早期版本的 POSIX 的功能测试宏:
|
下表列出了适用于早期版本的 X/Open CAE 规范的准则:
|
SVID3 规范未指定任何功能测试宏用于指示编写的应用程序符合 SVID3 要求。SVID3 规范是在 C 标准完成之前编写的。
csh(1)、ksh(1)、sh(1)、exec(2)、sysconf(3C)、system(3C)、environ(7)、lf64(7)