Jump to 
content
HP.com Home Products and Services Support and Drivers Solutions How to Buy
»  Contact HP

 

HP C

HP C
Language Reference Manual


Previous Contents Index

8.8.6 The __STDC_ISO_10646__ Macro

The __STDC_ISO_10646__ macro evaluates to an integer constant of the form yyyymmL (for example, 199712L), intended to indicate that values of type wchar_t are the coded representations of the characters defined by ISO/IEC 10646, along with all amendments and technical corrigenda as of the specified year and month.

8.8.7 System-Identification Macros

HP C defines platform-specific macros that can be used to identify the system on which the program is running. These macros can assist in writing code that executes conditionally depending on whether the program is running on an HP system or some other system, or one HP C platform or another.

These macro definitions can be used to separate portable and nonportable code in a C program by enclosing the nonportable code in conditionally compiled sections.

They can also be used to conditionally compile sections of C programs used on more than one operating system to take advantage of system-specific features. See Section 8.2 for more information about using the conditional-compilation preprocessor directives.

See your platform-specific HP C documentation for a list of the system-identification macros.

8.9 The __func__ Predeclared Identifier

The __func__ predeclared identifier evaluates to a static array of char initialized with the spelling of the function's name. It is visible anywhere within the body of a function definition.

For example, a function defined as follows will print "f1".


void f1(void) {printf("%s\n", __func__);} 


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 HP C platforms. See your HP 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);

  • Puts diagnostics into programs. If expression is false (zero), the assert macro writes information about the particular call that failed on the standard error file in an implementation-defined format. It then calls the abort function. The assert macro returns no value.

9.2 Complex Arithmetic(<complex.h>)

The <complex.h> header file defines macros and declares functions that support complex arithmetic.

Each synopsis specifies a family of functions consisting of a principal function with one or more double complex parameters and a double complex or double return value; and other functions with the same name but with f and l suffixes which are corresponding functions with float and long double parameters and return values.

Macros

complex

  • Expands to _Complex.

_Complex_I

  • Expands to a constant expression of type const float _Complex, with the value of the imaginary unit. The imaginary unit is a number i such that i2 = -1 .

imaginary
_Imaginary_I

  • Defined if and only if the implementation supports imaginary types; if defined, they expand to _Imaginary and a constant expression of type const float _Imaginary with the value of the imaginary unit.

I

  • Expands to _Imaginary_I or _Complex_I. If _Imaginary_I is not defined, I expands to _Complex_I.

Trigonometric Functions

The cacos functions


#include <complex.h> 
double complex cacos(double complex z); 
float complex cacosf(float complex z); 
long double complex cacosl(long double complex z); 

  • The cacos functions compute the complex arc cosine of z, with branch cuts outside the interval [ - 1,+1] along the real axis.
    The cacos functions return the value, in radians, of the complex arc cosine of z in the range of a strip mathematically unbounded along the imaginary axis and in the interval [0, pi] along the real axis.

The casin functions


#include <complex.h> 
double complex casin(double complex z); 
float complex casinf(float complex z); 
long double complex casinl(long double complex z); 

  • The casin functions compute the complex arc sine of z, with branch cuts outside the interval [ - 1,+1] along the real axis.
    The casin functions return the value, in radians, of the complex arc sine of z in the range of a strip mathematically unbounded along the imaginary axis and in the interval [-pi/2,+pi/2] along the real axis.

The catan functions


#include <complex.h> 
double complex catan(double complex z); 
float complex catanf(float complex z); 
long double complex catanl(long double complex z); 

  • The catan functions compute the complex arc tangent of z, with branch cuts outside the interval [ - i,+i] along the imaginary axis.
    The catan functions return the value, in radians, of the complex arc tangent of z in the range of a strip mathematically unbounded along the imaginary axis and in the interval [-pi/2,+pi/2] along the real axis.

The ccos functions


#include <complex.h> 
double complex ccos(double complex z); 
float complex ccosf(float complex z); 
long double complex ccosl(long double complex z); 

  • The ccos functions return the complex cosine of z.

The csin functions


#include <complex.h> 
double complex csin(double complex z); 
float complex csinf(float complex z); 
long double complex csinl(long double complex z); 

  • The csin functions return the complex sine of z.

The ctan functions


#include <complex.h> 
double complex ctan(double complex z); 
float complex ctanf(float complex z); 
long double complex ctanl(long double complex z); 

  • The ctan functions return the complex tangent of z.

Hyperbolic Functions

The cacosh functions


#include <complex.h> 
double complex cacosh(double complex z); 
float complex cacoshf(float complex z); 
long double complex cacoshl(long double complex z); 

  • The cacosh functions compute the complex arc hyperbolic cosine of z, with a branch cut at values less than 1 along the real axis.
    The cacosh functions return the value, in radians, of the complex arc hyperbolic cosine of z in the range of a a half-strip of non-negative values along the real axis and in the interval [-i(pi), +i(pi)] along the imaginary axis.

The casinh functions


#include <complex.h> 
double complex casinh(double complex z); 
float complex casinhf(float complex z); 
long double complex casinhl(long double complex z); 

  • The casinh functions compute the complex arc hyperbolic sine of z, with branch cuts outside the interval [ - i,+i] along the imaginary axis.
    The casinh functions return the complex arc hyperbolic sine value, in the range of a strip mathematically unbounded along the real axis and in the interval [-i(pi)/2, +i(pi)/2] along the imaginary axis.

The catanh functions


#include <complex.h> 
double complex catanh(double complex z); 
float complex catanhf(float complex z); 
long double complex catanhl(long double complex z); 

  • The catanh functions compute the complex arc hyperbolic tangent of z, with branch cuts outside the interval [ - 1,+1] along the real axis.
    The catanh functions return the complex arc hyperbolic tangent value, in the range of a strip mathematically unbounded along the real axis and in the interval [-i(pi)/2, +i(pi)/2] along the imaginary axis.

The ccosh functions


#include <complex.h> 
double complex ccosh(double complex z); 
float complex ccoshf(float complex z); 
long double complex ccoshl(long double complex z); 

  • The ccosh functions return the complex hyperbolic cosine of z.

The csinh functions


#include <complex.h> 
double complex csinh(double complex z); 
float complex csinhf(float complex z); 
long double complex csinhl(long double complex z); 

  • The csinh functions return the complex hyperbolic sine of z.

The ctanh functions


#include <complex.h> 
double complex ctanh(double complex z); 
float complex ctanhf(float complex z); 
long double complex ctanhl(long double complex z); 

  • The ctanh functions return the complex hyperbolic tangent of z.

Exponential and Logarithmic Functions

The cexp functions


#include <complex.h> 
double complex cexp(double complex z); 
float complex cexpf(float complex z); 
long double complex cexpl(long double complex z); 

  • The cexp functions return the complex base e exponential of z.

The clog functions


#include <complex.h> 
double complex clog(double complex z); 
float complex clogf(float complex z); 
long double complex clogl(long double complex z); 

  • The clog functions compute the complex natural (base e) logarithm of z, with a branch cut along the negative real axis.
    The clog functions return the complex natural logarithm value, in the range of a strip mathematically unbounded along the real axis and in the interval [-i(pi), +i(pi)] along the imaginary axis.

Power and Absolute-Value Functions

The cabs functions


#include <complex.h> 
double cabs(double complex z); 
float cabsf(float complex z); 
long double cabsl(long double complex z); 

  • The cabs functions return the complex absolute value (also called norm, modulus, or magnitude) of z.

The cpow functions


#include <complex.h> 
double complex cpow(double complex x, double complex y); 
float complex cpowf(float complex x, float complex y); 
long double complex cpowl(long double complex x, 
                          long double complex y); 

  • The cpow functions compute the complex power function xy, with a branch cut for the first parameter along the negative real axis.
    The cpow functions return the complex power function value.

The csqrt functions


#include <complex.h> 
double complex csqrt(double complex z); 
float complex csqrtf(float complex z); 
long double complex csqrtl(long double complex z); 

  • The csqrt functions compute the complex square root of z, with a branch cut along the negative real axis.
    The csqrt functions return the complex square root value, in the range of the right half-plane (including the imaginary axis).

Manipulation Functions

The carg functions


#include <complex.h> 
double carg(double complex z); 
float cargf(float complex z); 
long double cargl(long double complex z); 

  • The carg functions compute the argument (also called phase angle) of z, with a branch cut along the negative real axis.
    The carg functions return the value of the argument in the interval [-pi,+pi].

The cimag functions


#include <complex.h> 
double cimag(double complex z); 
float cimagf(float complex z); 
long double cimagl(long double complex z); 

  • The cimag functions compute the imaginary part of z and return it as a real.

The conj functions


#include <complex.h> 
double complex conj(double complex z); 
float complex conjf(float complex z); 
long double complex conjl(long double complex z); 

  • The conj functions compute complex conjugate of z, by reversing the sign of its imaginary part.
    The conj functions return the complex conjugate value.

The cproj functions


#include <complex.h> 
double complex cproj(double complex z); 
float complex cprojf(float complex z); 
long double complex cprojl(long double complex z); 

  • The cproj functions compute a projection of z onto the Riemann sphere: z projects to z except that all complex infinities (even those with one infinite part and one NaN part) project to positive infinity on the real axis. If z has an infinite part, then cproj(z) is equivalent to:


    INFINITY + I * copysign(0.0, cimag(z)) 
    

    The cproj functions return the value of the projection onto the Riemann sphere.

The creal functions


#include <complex.h> 
double creal(double complex z); 
float crealf(float complex z); 
long double creall(long double complex z); 

  • The creal functions compute and return the real part of z.
    For a variable z of complex type, z :=,= creal(z) + cimag(z)*I.

9.3 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);

  • Returns a nonzero integer if the character passed to it is an alphanumeric ASCII character. Otherwise, isalnum returns 0.

int isalpha(int c);

  • Returns a nonzero integer if the character passed to it is an alphabetic ASCII character. Otherwise, isalpha returns 0.

int iscntrl(int c);

  • Returns a nonzero integer if the character passed to it is an ASCII DEL character (177 octal, 0x7F hex) or any nonprinting ASCII character (a code less than 40 octal, 0x20 hex). Otherwise, iscntrl returns 0.

int isdigit(int c);

  • Returns a nonzero integer if the character passed to it is a decimal digit character (0 to 9). Otherwise, isdigit returns 0.

int isgraph(int c);

  • Returns a nonzero integer if the character passed to it is a graphic ASCII character (any printing character except a space character). Otherwise, isgraph returns 0.

int islower(int c);

  • Returns a nonzero integer if the character passed to it is a lowercase alphabetic ASCII character. Otherwise, islower returns 0.

int isprint(int c);

  • Returns a nonzero integer if the character passed to it is an ASCII printing character, including a space character. Otherwise, isprint returns 0.

int ispunct(int c);

  • Returns a nonzero integer if the character passed to it is an ASCII punctuation character (any printing character that is nonalphanumeric and greater than 40 octal, 0x20 hex). Otherwise, ispunct returns 0.

int isspace(int c);

  • Returns a nonzero integer if the character passed to it is white space. Otherwise, isspace returns 0. The standard white space characters are:
    • space (' ')
    • form feed ('\f')
    • new line ('\n')
    • carriage return ('\r')
    • horizontal tab ('\t')
    • vertical tab ('\v')

int isupper(int c);

  • Returns a nonzero integer if the character passed to it is an uppercase alphabetic ASCII character. Otherwise, isupper returns 0.

int isxdigit(int c);

  • Returns a nonzero integer if the character passed to it is a hexadecimal digit (0 to 9, A to F, or a to f). Otherwise, isxdigit returns 0.

int tolower(int c);

  • Converts an uppercase letter to lowercase. c remains unchanged if it is not an uppercase letter.

int toupper(int c);

  • Converts a lowercase letter to uppercase. c remains unchanged if it is not a lowercase letter.


Previous Next Contents Index

Privacy statement Using this site means you accept its terms
© 2007 Hewlett-Packard Development Company, L.P.