DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Complying with standard C

Names reserved for implementation use

The Standard places further restrictions on implementations regarding their libraries. While in the past, most programmers learned not to use names like read and write for their own functions on UNIX® Systems (usually after encountering interesting program behavior), ANSI C requires that only names reserved by the Standard be introduced by references within the implementation.

Thus the Standard reserves a subset of all possible names for implementations to use as they so choose. This class of names consists of identifiers that begin with an underscore and continue with either another underscore or a capital letter. The class of names contains all names matching the following regular expression:

   _[_A-Z][0-9_a-zA-Z]*
Strictly speaking, if your program uses such an identifier, its behavior is undefined. Thus, programs using _POSIX_SOURCE (or _XOPEN_SOURCE) have undefined behavior.

However, undefined behavior comes in different degrees. If, in a POSIX-conforming implementation you use _POSIX_SOURCE, you know that your program's ``undefined behavior'' consists of certain additional names in certain headers, and your program still conforms to an accepted standard. This deliberate loophole in the ANSI C standard allows implementations to conform to seemingly incompatible specifications. On the other hand, an implementation that does not conform to the POSIX standard is free to behave in any manner when encountering a name such as _POSIX_SOURCE.

The Standard also reserves all other names that begin with an underscore for use in header files as regular file scope identifiers and as tags for structures and unions, but not in local scopes. This means that the common existing practice of having functions named _filbuf and _doprnt to implement hidden parts of the library is sanctioned.


Next topic: Names reserved for expansion
Previous topic: Standard headers

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005