DEC C
Language Reference Manual


Previous Contents Index


Chapter 9
The ANSI C Standard Library

The ANSI C standard defines a set of functions, as well as related types and macros, to be provided with any implementation of ANSI C. This chapter lists and briefly describes the ANSI-conformant library features common to all DEC C platforms. See your DEC C library routine documentation for a detailed description of these routines and their use in your system environment, and for additional headers, functions, types, and macros that may be available on your operating system.

All library functions are declared in a header file. To make the contents of a header file available to your program, include the header file with an #include preprocessor directive. For example:


#include <stddef.h> 

Each header file declares a set of related functions, as well as defining any types and macros needed for their use.

The standard headers are:

Header files can be included in any order. Each can be included more than once in a given scope with no effect different from being included once. However, the effect of including <assert.h> depends on the definition of NDEBUG. Include headers outside of any external declaration or definition, and before any reference to the functions, types, or macros declared or defined in the headers. If an identifier is declared or defined in more than one included header, the second and subsequent headers containing that identifier can be included after the initial reference to that identifier.

9.1 Diagnostics (<assert.h>)

The header <assert.h> defines the assert macro and refers to another macro, NDEBUG, defined elsewhere. If NDEBUG is defined as a macro name at the point in the source file where <assert.h> is included, the assert macro is defined as follows:


#define assert(ignore) ((void) 0) 

Macro

void assert(int expression);

9.2 Character Processing (<ctype.h>)

The <ctype.h> header file declares several functions for testing characters. For each function, the argument is an int whose value must be EOF or representable as an unsigned char, and the return value is an integer.

Functions

int isalnum(int c);

int isalpha(int c);

int iscntrl(int c);

int isdigit(int c);

int isgraph(int c);

int islower(int c);

int isprint(int c);

int ispunct(int c);

int isspace(int c);

int isupper(int c);

int isxdigit(int c);

int tolower(int c);

int toupper(int c);

9.3 Error Codes (<errno.h>)

The <errno.h> header file defines several macros used for error reporting.

Macros

EDOM
ERANGE

Variable or Macro

errno

9.4 ANSI C Limits (<limits.h> and <float.h>)

The <limits.h> and <float.h> header files define several macros that expand to various implementation-specific limits and parameters, most of which describe integer and floating-point properties of the hardware. See your platform-specific DEC C documentation for details.

9.5 Localization (<locale.h>)

The <locale.h> header file declares two functions and one type and defines several macros.

Type

struct lconv

Macros

NULL
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MONETARY
LC_NUMERIC
LC_TIME

Functions

char *setlocale(int category, const char *locale);

struct lconv *localeconv(void);

9.6 Mathematics (<math.h>)

The <math.h> header file defines one macro and several mathematical functions. The functions take double arguments and return double-precision values.

The behavior of the functions in this header is defined for all representable values of their input arguments. Each function executes as if it were a single operation, without generating any externally visible exceptions.

For all functions, a domain error occurs if an input argument is outside the domain over which the mathematical function is defined. The description of each function lists any domain errors. On a domain error, the function returns an implementation-defined value; the value of the EDOM macro is stored in errno.

For all functions, a range error occurs if the result of the function cannot be represented as a double value. If the result overflows (the magnitude of the result is so large that it cannot be represented in an object of the specified type), the function returns the value of the macro HUGE_VAL, with the same sign (except for the tan function) as the correct value of the function; the value of the ERANGE macro is stored in errno. If the result underflows (the magnitude of the result is so small that it cannot be represented in an object of the specified type), the function returns 0; whether the value of the ERANGE macro is stored in errno is implementation-defined.

Macros

HUGE_VAL

Trigonometric Functions

double acos(double x);

double asin(double x);

double atan(double x);

double atan2(double y, double x);

double cos(double x);

double sin(double x);

double tan(double x);

Hyperbolic Functions

double cosh(double x);

double sinh(double x);

double tanh(double x);

Exponential and Logarithmic Functions

double exp(double x);

double frexp(double value, int *eptr);

double ldexp(double x, int exp);

double log(double x);

double log10(double x);

double modf(double value, double *iptr);


Previous Next Contents Index