Expert C Programming

(Jeff_L) #1

setlocale setvbuf SHRT_MAX SHRT_MIN


SIG_[A-Z]anything sig_atomic_t SIG_DFL SIG_ERR


SIG_IGN (^) SIG[A-Z]anything SIGABRT SIGFPE


SIGILL SIGINT signal SIGSEGV


SIGTERM sin,-f,-l sinh,-f,-l size_t


sprintf sqrt,-f,-l


srand sscanf stderr stdin


stdout str[a-z]anything system tan,-f,-l


tanh,-f,-l thousands_sep time time_t


tm tm_hour tm_isdst tm_mday


tm_min tm_mon tm_sec tm_wday


tm_yday tm_year TMP_MAX tmpfile


tmpnam to[a-z]anything UCHAR_MAX UINT_MAX


ULONG_MAX ungetc USHRT_MAX va_arg


va_end va_list va_start vfprintf


vprintf vsprintf wchar_t (^) wcs[a-z]anything


wcstombs wctomb


Remember that under ANSI section 6.1.2 (Identifiers), an implementation can define letter case not
significant for external identifiers. Also, external identifiers only need be significant in the first six
characters (ANSI section 5.2.4.1, Translation Limits). Both of these expand the number of identifiers
that you should avoid. The list above consists of the C library symbols that you may not redefine.
There will be additional symbols for each additional library you link against. Check the ABI
document [2] for a list of these.


[2] The System V Application Binary Interface, AT&T, 1990.


The problem of name space pollution is only partially addressed in ANSI C. ANSI C out-laws a user
redefining a system name (effectively outlawing interpositioning) in section 7.1.2.1:


7.1.2.1 Reserved Identifiers: All identifiers with external linkage in any of the following sections
[what follows is a number of sections defining the standard library functions]...are always reserved
for use as identifiers with external linkage.


If an identifier is reserved, it means that the user is not allowed to redefine it. However, this is not a
constraint, so it does not require an error message when it sees it happen. It just causes unportable,
undefined behavior. In other words, if one of your function names is the same as a C library function
name (deliberately or inadvertently), you have created a nonconforming program, but the translator is
not obliged to warn you about it. We would much rather the standard required the compiler to issue a
warning diagnostic, and let it make up its own mind about stuff like the maximum number of case
labels it can handle in a switch statement.


Generating Linker Report Files


Use the "-m" option to ld for a linker report that includes a note of symbols which have been


interposed. In general, the "-m" option to ld will produce a memory map or listing showing what has

Free download pdf