DEC C
Language Reference Manual


Previous Contents Index

8.6 Error Directive (#error)

The #error preprocessor directive issues a diagnostic message and ends compilation. 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 System-Identification Macros

DEC 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 Digital system or some other system, or one DEC 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 DEC C documentation for a list of the system-identification macros.


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(intexpression);

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(intc);

int isalpha(intc);

int iscntrl(intc);

int isdigit(intc);

int isgraph(intc);

int islower(intc);

int isprint(intc);

int ispunct(intc);

int isspace(intc);

int isupper(intc);

int isxdigit(intc);

int tolower(intc);

int toupper(intc);

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


Previous Next Contents Index