The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 The Compilation Environment

Applications should ensure that the feature test macro _XOPEN_SOURCE is defined with the value 500 before inclusion of any header. This is needed to enable the functionality described in this specification, and possibly to enable functionality defined elsewhere in the Common Applications Environment.

Identifiers in this specification may only be undefined using the #undef directive as described in Use and Implementation of Interfaces or The X/Open Name Space . These #undef directives must follow all #include directives of any XSI headers.

Most strictly conforming POSIX and ISO C applications will compile on systems compliant to this specification. However, an application which uses any of the items marked as an extension to POSIX and ISO C, for any purpose other than that shown here, will not necessarily compile. In such cases, it may be necessary to alter those applications to use alternative identifiers.

Since this specification is aligned with the ISO C standard, and since all functionality enabled by _POSIX_C_SOURCE set greater than zero and less than or equal to 199506L should be enabled by _XOPEN_SOURCE set equal to 500, there should be no need to define either _POSIX_SOURCE or _POSIX_C_SOURCE if _XOPEN_SOURCE is so defined. Therefore if _XOPEN_SOURCE is set equal to 500 and _POSIX_SOURCE is defined, or _POSIX_C_SOURCE is set greater than zero and less than or equal to 199506L, the behaviour is the same as if only _XOPEN_SOURCE is defined and set equal to 500. However, should _POSIX_C_SOURCE be set to a value greater than 199506L, the behaviour is undefined.

 The X/Open Name Space

All identifiers in this specification except environ are defined in at least one of the headers, as shown in . When _XOPEN_SOURCE is defined, each header defines or declares some identifiers, potentially conflicting with identifiers used by the application. The set of identifiers visible to the application consists of precisely those identifiers from the header pages of the included headers, as well as additional identifiers reserved for the implementation. In addition, some headers may make visible identifiers from other headers as indicated on the relevant header pages.

An implementation conforming to the referenced Networking Services, Issue 5 specification will define or declare an additional set of identifiers as shown in the XNS Name Space or the XNS reference pages.

The identifiers reserved for use by the implementation are described below.

  1. Each identifier with external linkage described in the header section is reserved for use as an identifier with external linkage if the header is included.

  2. Each macro name described in the header section is reserved for any use if the header is included.

  3. Each identifier with file scope described in the header section is reserved for use as an identifier with file scope in the same name space if the header is included.

If any header in the following table is included, identifiers with the prefixes, suffixes or complete names shown are reserved for any use by the implementation.


Header Prefix Suffix Complete Name
<aio.h> aio_, lio_, AIO_, LIO_    
<dirent.h> d_    
<errno.h> E    
<fcntl.h> l_    
<glob.h> gl_    
<grp.h> gr_    
<limits.h>   _MAX  
<locale.h> LC_[A-Z]    
<mqueue.h> mq_, MQ_    
<ndbm.h> dbm_    
<poll.h> pd_, ph_, ps_    
<pthread.h> pthread_, PTHREAD_    
<pwd.h> pw_    
<regex.h> re_, rm_    
<sched.h> sched_, SCHED_    
<semaphore.h> sem_, SEM_    
<signal.h> sa_, SIG[A-Z], SIG_[A-Z], ss_, sv_, si_, SI_, sigev_, SIGEV_, sival_, uc_    
<stropts.h> bi_, ic_, l_, sl_, str_    
<sys/ipc.h> ipc_   key, pad, seq
<sys/mman.h> shm_, MAP_, MCL_, MS_, PROT_    
<sys/msg.h> msg   msg
<sys/resource.h> rlim_, ru_    
<sys/sem.h> sem   sem
<sys/shm.h> shm    
<sys/stat.h> st_    
<sys/statvfs.h> f_    
<sys/time.h> fds_, it_, tv_, FD_    
<sys/times.h> tms_    
<sys/uio.h> iov_    
<sys/utsname.h> uts_    
<sys/wait.h> si_, W[A-Z], P_    
<termios.h> c_    
<time.h> tm_, clock_, timer_, it_, tv_, CLOCK_, TIMER_    
<ucontext.h> uc_, ss_    
<ulimit.h> UL_    
<utime.h> utim_    
<utmpx.h> ut_ _LVL, _TIME, _PROCESS  
<wordexp.h> we_    
ANY header   _t  

Note:
The notation [A-Z] indicates any upper-case letter in the portable character set. The notation [a-z] indicates any lower-case letter in the portable character set. Commas and spaces in the lists of prefixes and complete names in the above table are not part of any prefix or complete name.
If any header in the following table is included, macros with the prefixes shown may be defined. After the last inclusion of a given header, an application may use identifiers with the corresponding prefixes for its own purpose, provided their use is preceded by an #undef of the corresponding macro.

Header Prefix
<dlfcn.h> RTLD_        
<fcntl.h> F_ O_ S_    
<fmtmsg.h> MM_        
<fnmatch.h> FNM_        
<ftw.h> FTW        
<glob.h> GLOB_        
<ndbm.h> DBM_        
<nl_types.h> NL_        
<poll.h> POLL        
<regex.h> REG_        
<signal.h> SA_ SIG_[0-9a-z_]      
  BUS_ CLD_ FPE_ ILL_ POLL_
  SEGV_ SI_ SS_ SV_ TRAP_
<stropts.h> FLUSH[A-Z] I_ M_ MUXID_R[A-Z]  
  S_ SND[A-Z] STR    
<syslog.h> LOG_        
<sys/ipc.h> IPC_        
<sys/mman.h> PROT_ MAP_ MS_    
<sys/msg.h> MSG[A-Z] MSG_[A-Z]      
<sys/resource.h> PRIO_ RLIM_ RLIMIT_ RUSAGE_  
<sys/sem.h> SEM_        
<sys/shm.h> SHM[A-Z] SHM_[A-Z]      
<sys/socket.h> AF_ MSG_ PF_ SO  
<sys/stat.h> S_        
<sys/statvfs.h> ST_        
<sys/time.h> FD_ ITIMER_      
<sys/uio.h> IOV_        
<sys/wait.h> BUS_ CLD_ FPE_ ILL_ POLL_
  SEGV_ SI_ TRAP_    
<termios.h> V I O TC B[0-9]
<wordexp.h> WRDE_        

Note:
The notation [0-9] indicates any digit. The notation [A-Z] indicates any upper-case letter in the portable character set. The notation [0-9a-z_] indicates any digit, any lower-case letter in the portable character set or underscore.

The following identifiers are reserved regardless of the inclusion of headers.

  1. All identifiers that begin with an underscore and either an upper-case letter or another underscore are always reserved for any use by the implementation.

  2. All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary identifier and tag name spaces.

  3. All identifiers in the table below are reserved for use as identifiers with external linkage. Some of these identifiers do not appear in this specification, but are reserved for future use by the ISO C standard.

    abort abs acos acosf acosl asctime asin asinf asinl atan atan2 atan2f atan2l atanf atanl atexit atof atoi atol bsearch calloc ceil ceilf ceill clearerr clock cos cosf cosh coshf coshl cosl ctime difftime div errno exit exp expf expl fabs fabsf fabsl fclose feof ferror fflush fgetc fgetpos fgets fgetwc fgetws floor floorf floorl fmod fmodf fmodl fopen fprintf fputc fputs fputwc fputws fread free freopen frexp frexpf frexpl fscanf fseek fsetpos ftell fwide fwprintf fwrite fwscanf getc getchar getenv gets getwc getwchar gmtime is[a-z]* labs ldexp ldexpf ldexpl ldiv localeconv localtime log log10 log10f log10l logf logl longjmp malloc mblen mbrlen mbrtowc mbsinit mbsrtowcs mbstowcs mbtowc mem[a-z]* mktime modf modff modfl perror pow powf powl printf putc putchar puts putwc putwchar qsort raise rand realloc remove rename rewind scanf setbuf setjmp setlocale setvbuf signal sin sinf sinh sinhf sinhl sinl sprintf sqrt sqrtf sqrtl srand sscanf str[a-z]* swprintf swscanf system tan tanf tanh tanhf tanhl tanl time tmpfile tmpnam to[a-z]* ungetc ungetwc va_end vfprintf vfwprintf vprintf vsprintf vswprintf vwprintf wcrtomb wcs[a-z]* wctob wctomb wctrans wctype wcwidth wmem[a-z]* wprintf wscanf

    Note:
    The notation [a-z] indicates any lower-case letter in the portable character set. The notation * indicates any combination of digits, letters in the portable character set, and underscore.


4.
The following identifiers are also reserved for use as identifiers with external linkage:

a64l endservent getpgid logb regex sigset
acosh endutxent getpmsg lstat remainder sigstack
asinh expm1 getpriority makecontext remque srandom
atanh fattach getpwent mknod rindex statvfs
basename fchdir getrlimit mkstemp rint strcasecmp
bcmp fchmod getrusage mktemp sbrk strdup
bcopy fchown getsid mmap scalb strncasecmp
brk fcvt getsubopt mprotect select swapcontext
bsd_signal fdetach gettimeofday msync setcontext symlink
bzero ffs getutxent munmap setgrent sync
cbrt fmtmsg getutxid nextafter setitimer syslog
closelog fstatvfs getutxline nftw setlogmask tcgetsid
dbm_clearerr ftime getwd openlog setpgrp truncate
dbm_close ftok grantpt poll setpriority ttyslot
dbm_delete ftruncate ilogb ptsname setpwent ualarm
dbm_error gcvt index putmsg setreuid unlockpt
dbm_fetch getcontext initstate putpmsg setrlimit usleep
dbm_firstkey getdate insque pututxline setstate utimes
dbm_nextkey getdtablesize ioctl random setutxent valloc
dbm_open getgrent isastream re_comp sigaltstack vfork
dbm_store getgrgid killpg re_exec sighold wait3
dirname gethostid l64a readlink sigignore waitid
ecvt getitimer lchown readv siginterrupt writev

All the identifiers defined in this specification that have external linkage are always reserved for use as identifiers with external linkage.

No other identifiers are reserved.

Applications must not declare or define identifiers with the same name as an identifier reserved in the same context. Since macro names are replaced whenever found, independent of scope and name space, macro names matching any of the reserved identifier names must not be defined if any associated header is included.

Except that the effect of each inclusion of <assert.h> depends on the definition of NDEBUG, headers may be included in any order, and each may be included more than once in a given scope, with no difference in effect from that of being included only once.

If used, a header must be included outside of any external declaration or definition, and it must be first included before the first reference to any type or macro it defines, or to any function or object it declares. However, if an identifier is declared or defined in more than one header, the second and subsequent associated headers may be included after the initial reference to the identifier. Prior to the inclusion of a header, the program must not define any macros with names lexically identical to symbols defined by that header.


UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]