Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   unistd.h.0p    ( 10 )

стандартные символьные константы и типы (standard symbolic constants and types)

  Prolog  |  Name  |  Synopsis  |  Description  |    Application usage    |  Rationale  |  Future directions  |  See also  |

Использование в приложениях (Application usage)

POSIX.1‐2008 only describes the behavior of systems that claim conformance to it. However, application developers who want to write applications that adapt to other versions of this standard (or to systems that do not conform to any POSIX standard) may find it useful to code them so as to conditionally compile different code depending on the value of _POSIX_VERSION, for example:

#if _POSIX_VERSION >= 200112L /* Use the newer function that copes with large files. */ off_t pos=ftello(fp); #else /* Either this is an old version of POSIX, or _POSIX_VERSION is not even defined, so use the traditional function. */ long pos=ftell(fp); #endif

Earlier versions of POSIX.1‐2008 and of the Single UNIX Specification can be identified by the following macros:

POSIX.1‐1988 standard _POSIX_VERSION==198808L

POSIX.1‐1990 standard _POSIX_VERSION==199009L

ISO POSIX‐1:1996 standard _POSIX_VERSION==199506L

Single UNIX Specification, Version 1 _XOPEN_UNIX and _XOPEN_VERSION==4

Single UNIX Specification, Version 2 _XOPEN_UNIX and _XOPEN_VERSION==500

ISO POSIX‐1:2001 and Single UNIX Specification, Version 3 _POSIX_VERSION==200112L, plus (if the XSI option is supported) _XOPEN_UNIX and _XOPEN_VERSION==600

POSIX.1‐2008 does not make any attempt to define application binary interaction with the underlying operating system. However, application developers may find it useful to query _SC_VERSION at runtime via sysconf() to determine whether the current version of the operating system supports the necessary functionality as in the following program fragment:

if (sysconf(_SC_VERSION) < 200809L) { fprintf(stderr, "POSIX.1-2008 system required, terminating \n"); exit(1); }

New applications should not use _XOPEN_SHM or _XOPEN_ENH_I18N.