| |||||||||||||
On-Line Manuals RealView Compiler User's Guide | Library features
The C99 standard introduces several new library features of interest to programmers, including:
A selection of new library features of C99 that might be of particular interest are discussed in the following sections. C99 supports additional macros, types, and functions in the standard header New macros found in C99 that are not found in C90 include: INFINITY // positive infinity NAN // IEEE not‑a‑number New generic function macros found in C99 that are not found in C90 include: #define isinf(x) // non‑zero only if x is positive or negative infinity #define isnan(x) // non‑zero only if x is NaN #define isless(x, y) // 1 only if x < y and x and y are not NaN, and 0 otherwise #define isunordered(x, y) // 1 only if either x or y is NaN, and 0 otherwise New mathematical functions found in C99 that are not found in C90 include: double acosh(double x); // hyperbolic arccosine of x double asinh(double x); // hyperbolic arcsine of x double atanh(double x); // hyperbolic arctangent of x double erf(double x); // returns the error function of x double round(double x); // returns x rounded to the nearest integer double tgamma(double x); // returns the gamma function of x C99 supports the new mathematical functions for all real floating‑point types. Single precision versions of all existing C99 introduces the native type _Bool. The associated standard header
#include <stdbool.h>
bool foo(FILE *str)
{
bool err = false;
...
if (!fflush(str))
{
err = true;
}
...
return err;
}
NoteThe C99 semantics for bool are intended to match those of C++. In C90, the long data type can serve both as the largest integral type, and as a 32‑bit container. C99 removes this ambiguity through the new standard library header files The header file
The header file intmax_t imaxabs(intmax_t x); // absolute value of x imaxdiv_t imaxdiv(intmax_t x, intmax_t y) // returns the quotient and remainder // of x / y The C99 standard header file The new types supported are:
New macros supported include:
New functions include: int feclearexcept(int ex); // clear floating‑point exceptions selected by ex int feraiseexcept(int ex); // raise floating point exceptions selected by ex int fetestexcept(int ex); // test floating point exceptions selected by x int fegetround(void); // return the current rounding mode int fesetround(int mode); // set the current rounding mode given by mode int fegetenv(fenv_t *penv); return the floating‑point environment in penv int fesetenv(const fenv_t *penv); // set the floating‑point environment to penv Using the sprintf(buffer, size, "Error %d: Cannot open file '%s'", errno, filename); the variable The snprintf(buffer, size, "Error %d: Cannot open file '%s'", errno, filename); the variable The new standard header extern float cos(float x); extern double cos(double x); extern long double cos(long double x); ... A statement such as: p = cos(0.78539f); // p = cos(pi / 4) calls the single‑precision version of the NoteType‑generic families of mathematical functions can be defined in C++ using the operator overloading mechanism. The semantics of type-generic families of functions defined using operator overloading in C++ are different from the semantics of the corresponding families of type‑generic functions defined in | ||||||||||||
| |||||||||||||