United States    
COMPAQ STORE | PRODUCTS |
SERVICES | SUPPORT | CONTACT US | SEARCH
Compaq C

Compaq C
Language Reference Manual


Previous Contents Index

8.5 Implementation-Specific Preprocessor Directive (#pragma)

The #pragma directive is a standard method for implementing platform-dependent features. This directive has the following syntax:

#pragma pp-tokensopt newline

The supported pragmas vary across platforms. All unrecognized pragmas are diagnosed with an informational message. See your platform-specific Compaq C documentation for a list of supported pragmas.

Some pragma directives are subject to macro expansion. They are:


builtins            inline                 linkage       standard 
dictionary          noinline               module        nostandard 
extern_model        member_alignment       message       use_linkage 
extern_prefix       nomember_alignment 

The following pragmas are also subject to macro expansion, primarily for use in preprocess-only mode (that is, with the /PREPROCESS_ONLY qualifier on OpenVMS systems or the -E switch on Tru64 UNIX systems), and are not normally used when generating an object module with the Compaq C compiler:

Note

To provide macro-expansion support to those pragmas not listed above, all pragmas (including those that are already specified as undergoing macro expansion) have a pragma-name _m version, which makes the pragma subject to macro expansion. For example, #pragma assert is not subject to macro expansion, but #pragma assert_m is.

A macro reference can occur anywhere after the keyword pragma . For example:


#define opt inline 
#define f func 
#pragma opt(f) 

After both macros are expanded, the #pragma directive becomes #pragma inline (func) .

Note

Macro expansion is a feature of pragmas introduced in early versions of DEC C and is retained for backward compatibility.

Pragmas added in more recent versions of the compiler and pragmas added in the future have changed that practice to conform to the defacto industry standard of not performing macro expansion. (ANSI C places no requirement on macro expansion of pragmas.)

The following describes how the compiler decides whether or not to macro-expand a given pragma:

In compilation modes other than /STANDARD=COMMON (OpenVMS systems) or -std0 (Tru64 UNIX systems), do Step 1:

Step 1:

The token following the keyword pragma is first checked to see if it is a currently-defined macro. If it is a macro and the identifier does not match the name of a pragma that is not subject to macro expansion, then just that macro (with its arguments, if function-like) is expanded. The tokens produced by that macro expansion are then processed along with the rest of the tokens on the line in Step 2.

In all compilation modes, do Step 2:

Step 2:

The first token following the keyword pragma is checked to see if it matches the name of a pragma that is subject to macro expansion. If it does, then macro expansion is applied to that token and to the rest of tokens on the line.

The test for matching a known pragma permits an optional double leading underscore. For example, #pragma __nostandard is equivalent to #pragma standard .

Example

The following example illustrates that for pragmas coded directly with a name that matches a known pragma, the macro-expansion behavior is generally the same in all modes and is backward-compatible. It is only in cases where a pragma was coded with a name that was not the name of a known pragma, expecting macro expansion to produce the pragma name, that backward-compatibility is broken, and then only in common mode. The exception is made in common mode to maintain compatibility with the Tru64 UNIX preprocessor.


  #define pointer_size error 
  #define m1 e1 
  #define e1 pointer_size 32 
  #define standard message 
  #define x disable(all) 
  #define disable(y) enable(y) 
 
  #pragma pointer_size 32  /* In common mode, Step 1 skipped. 
                              In other modes, Step 1 finds that pointer_size 
                                   is known not to expand. 
                              In any mode, Step 2 finds pointer_size is 
                                   not a pragma requiring expansion. */ 
 
  #pragma m1   /* In common mode, Step 1 skipped. 
                  In other modes, Step 1 expands m1 to pointer_size 32. 
                  In common mode, Step 2 finds m1 is not a pragma requiring 
                         expansion. 
                  In other modes, Step 2 finds pointer_size is not a pragma 
                         requiring expansion. */ 
 
  #pragma standard x  /* In common mode, Step 1 skipped. 
                         In other modes, Step 1 expands to message x. 
                         In common mode, Step 2 expands to message enable(all). 
                         In other modes, Step 2 expands message x to 
                            message enable(all). */ 

8.6 Error Directive (#error)

The #error preprocessor directive issues an E-level diagnostic message and continues compilation, but no object module is produced. This directive has the following syntax:

#error messageopt newline

8.7 Null Directive (#)

A preprocessing directive of the form # newline is a null directive and has no effect.

8.8 Predefined Macro Names

The following sections describe the predefined macro names that are provided to assist in transporting code and performing simple tasks common to many programs.

8.8.1 The __DATE__ Macro

The __DATE__ macro evaluates to a string literal specifying the date on which the compilation started. The date has the following format:

"Mmm dd yyyy"

The names of the months are the same as those generated by the asctime library function. The first d is a space if dd is less than 10. For example:


printf("%s",_ _DATE_ _); 

The value of this macro remains constant throughout the translation unit.

8.8.2 The __FILE__ Macro

The __FILE__ macro evaluates to a string literal specifying the file specification of the current source file. For example:


printf("file %s", _ _FILE_ _); 

8.8.3 The __LINE__ Macro

The __LINE__ macro evaluates to a decimal constant specifying the number of the line in the source file containing the macro reference. For example:


printf("At line %d in file %s", _ _LINE_ _, _ _FILE_ _); 

8.8.4 The __TIME__ Macro

The __TIME__ macro evaluates to a string specifying the time that the compilation started. The time has the following format (the same as the asctime function):

hh:mm:ss

For example:


printf("%s", _ _TIME_ _); 

The value of this macro remains constant throughout the translation unit.

8.8.5 The __STDC__ Macro

The __STDC__ macro evaluates to the integer constant 1, which indicates a conforming implementation.

The value of this macro remains constant throughout the translation unit.

8.8.6 The __STDC_HOSTED__ Macro

The __STDC_HOSTED__ macro evaluates to the integer constant 1 if the implementation is a hosted implementation, or to the integer constant 0 if it is not.

8.8.7 The __STDC_VERSION__ Macro

The __STDC_VERSION__ macro evaluates to the integer constant 199901L.

8.8.8 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.9 System-Identification Macros

Compaq 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 a Compaq system or some other system, or one Compaq 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 Compaq 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 Compaq C platforms. See your Compaq 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 sign] 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 sign/2,+Pi sign/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 sign/2,+Pi sign/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 [-iPi sign,+iPi sign] 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 [-iPi sign/2,+iPi sign/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 [-iPi sign/2,+iPi sign/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 [-iPi sign,+iPi sign] along the imaginary axis.

Power and Absolute-Value Functions


Previous Next Contents Index
  

1.800.AT.COMPAQ

privacy and legal statement