[added with TR24731]
ISO/IEC TR24731 is a non-normative Technical Report titled Extensions to the C Library, Part 1: Bounds-checking interfaces. It adds a number of functions that check arguments for unexpected null pointers, short buffers, and other common errors. The functions are based on additions made by Microsoft to Visual C++ 2005 (V8). The additions all occur within existing headers.
__STDC_LIB_EXT1__ is defined as
200509L to indicate the presence of C Library Extension 1.
If you define the macro
as zero before you include any of the headers
that contain C Library Extension 1 additions, then none of these additions
will be visible to the program. Otherwise, in this
the library defines this macro as
1 and includes all the
C Library Extension 1 introduces the concept of a runtime constraint violation, which is a condition detected and reported at runtime. Examples include calling a function with an unexpected null pointer argument or with a buffer length argument that is too small or too large. The description of each library function describes any runtime constraints added with TR24731 that it enforces. (Note that some existing library functions have such added runtime constraints.)
A library function reports a runtime constraint violation by calling a
constraint handler, of type
constraint_handler_t, with three arguments:
const char *mesg-- a null-terminated error message
void *p-- a pointer, either null or to an implementation-defined object
errno_t errcode-- an error code suitable for assigning to
In this implementation, the library always calls
the constraint handler with
p a null pointer.
If the constraint handler returns, the library returns to the function
that reported the runtime constraint violation.
The default constraint handler writes
to the standard error stream and returns.
You can alter the constraint handler that gets called by calling
For convenience, the library supplies two functions that you can use as
abort_handler_s, which writes
mesgto the standard error stream and aborts
ignore_handler_s, which simply returns
You can also supply your own constraint handler.
Two useful synonyms for other types are:
typedef int errno_t, for representing error codes
typedef size_t rsize_t, for representing object sizes that should never be greater than the value of the macro
An implementation typically defines
as the size in bytes of the largest object that you can declare
or allocate dynamically. Note that:
RSIZE_MAX <= (size_t)(-1) / 2and
sizeof (int) <= sizeof (size_t)then a negative
intvalue converted to
rsize_twill cause a runtime constraint violation instead of being treated as a ridiculously large unsigned value
RSIZE_MAX == SIZE_MAXno runtime constraint violation can occur for any value of type
See also the Table of Contents and the Index.
Copyright © 1992-2013 by P.J. Plauger. All rights reserved.