Runtime-Support
Functions
-
Header
Files
6.1
Header
Files
Each
runtime-support function
is
declared in a header file.
Each
header file
declares:
• A set
of
related functions,
• Any types that you need
to
use
the functions,
and
• Any macros that you need
to
use the functions.
The header files that declare the runtime-support functions
are:
assert.h
limits.h
stddef.h
ctype.h
math.h
stdlib.h
errno.h
setjmp.h
string.h
float.h
stdarg.h
time.h
In order to
use
a runtime-support function, you must first use the #include
preprocessor directive
to
include the header file that declares the function.
For example, the isdigit function
is
declared by the
ctype.
h header. Before
you can
use
the isdigit function, you must first include the
ctype.
h file:
#include
<ctype.h>
val
=
isdigit(num)j
You can include headers in any order. You must include a header before you
reference any
of
the functions or objects that it declares.
Section 6.1.1 through Section 6.1.10 describe the header files that
are
in-
cluded
with
the TMS34010 C compiler. Section 6.2 (page
6-9)
lists the
functions that these headers declare.
6.1.1
Diagnostic
Messages
(assert.h)
6-2
The
assert.
h header defines the assert macro, which inserts diagnostic fail-
ure messages into programs at runtime. The assert macro tests a runtime ex-
pression.
If
the expression
is
true, the program continues running.
If
the
expression
is
false, the macro outputs a message that contains the expression,
the source file name, and the line number
of
the statement that contains the
expression; then, the program terminates (via the abort function).
The
assert.h
header refers to another macro named NDEBUG
(assert.h
does
not
define NDEBUG).
If
you have defined NDEBUG
as
a macro name
when you include
assert.
h, then the
assp-rt
macro
is
turned
off
and does
nothing.
If
NDEBUG is
not
defined, then the assert macro
is
enabled.
The assert macro
is
defined
as
follows:
#ifdef
NDEBUG
#define
assert(ignore)
#else
#define
assert(expr)
\
if
(I(expr»
{printf(ltAssertion
failed,
(expr),
file
%s,\
line
%d\nlt,
-FILE
__
,
--LINE-)j
abort()j
)
#endif