Lines Matching refs:code
14 * Consistency Checking:: Using @code{assert} to abort if
18 * Null Pointer Constant:: The macro @code{NULL}.
35 The @code{assert} macro, defined in the header file @file{assert.h},
41 checks performed by the @code{assert} macro by recompiling with the
42 macro @code{NDEBUG} defined. This means you don't actually have to
43 change the program source code to disable these checks.
58 If @code{NDEBUG} is not defined, @code{assert} tests the value of
59 @var{expression}. If it is false (zero), @code{assert} aborts the
68 on the standard error stream @code{stderr} (@pxref{Standard Streams}).
70 @code{__FILE__} and @code{__LINE__} and specify where the call to
71 @code{assert} was made. When using the GNU C compiler, the name of
72 the function which calls @code{assert} is taken from the built-in
73 variable @code{__PRETTY_FUNCTION__}; with older compilers, the function
76 If the preprocessor macro @code{NDEBUG} is defined before
77 @file{assert.h} is included, the @code{assert} macro is defined to do
81 evaluated if @code{NDEBUG} is in effect. So never use @code{assert}
82 with arguments that involve side effects. For example, @code{assert
83 (++i > 0);} is a bad idea, because @code{i} will not be incremented if
84 @code{NDEBUG} is defined.
90 The @code{assert_perror} macro makes this easy.
96 Similar to @code{assert}, but verifies that @var{errnum} is zero.
98 If @code{NDEBUG} is not defined, @code{assert_perror} tests the value of
99 @var{errnum}. If it is nonzero, @code{assert_perror} aborts the program
108 name are as for @code{assert}. The error text is the result of
109 @w{@code{strerror (@var{errnum})}}. @xref{Error Messages}.
111 Like @code{assert}, if @code{NDEBUG} is defined before @file{assert.h}
112 is included, the @code{assert_perror} macro does absolutely nothing. It
115 reference; often it will be @code{errno}.
120 @strong{Usage note:} The @code{assert} facility is designed for
125 The information in the diagnostic messages printed by the @code{assert}
126 and @code{assert_perror} macro is intended to help you, the programmer,
130 invalid input, as @code{assert} would do---it should exit with nonzero
172 @samp{foo} is declared with @code{int foo (int, char *);} then you must
181 a one-dimensional array with @code{malloc} to hold a specified set of
187 The library function @code{printf} (@pxref{Formatted Output}) is an
195 Some functions such as @code{open} take a fixed set of arguments, but
257 defines a function @code{func} which returns an @code{int} and takes two
258 required arguments, a @code{const char *} and an @code{int}. These are
262 argument must not be declared @code{register} in the function
266 @code{float}, @code{char} (whether signed or not) and @w{@code{short int}}
285 You initialize an argument pointer variable of type @code{va_list} using
286 @code{va_start}. The argument pointer when initialized points to the
290 You access the optional arguments by successive calls to @code{va_arg}.
291 The first call to @code{va_arg} gives you the first optional argument,
301 calling @code{va_end}.
303 (In practice, with most C compilers, calling @code{va_end} does nothing.
305 @code{va_end} just in case your program is someday compiled with a peculiar
309 @xref{Argument Macros}, for the full definitions of @code{va_start},
310 @code{va_arg} and @code{va_end}.
313 optional arguments. However, you can pass the @code{va_list} variable
322 can initialize each variable with @code{va_start} when you wish, and
330 portability, you should just pass it to @code{va_end}. This is actually
358 @code{printf} is one example of this (@pxref{Formatted Output Functions}).
364 otherwise meaningful to the function.) The @code{execl} function works
392 have to declare as variadic---for example, @code{open} and
393 @code{printf}.
400 type @code{char} or @w{@code{short int}} (whether signed or not) are
401 promoted to either @code{int} or @w{@code{unsigned int}}, as
402 appropriate; and that objects of type @code{float} are promoted to type
403 @code{double}. So, if the caller passes a @code{char} as an optional
404 argument, it is promoted to an @code{int}, and the function can access
405 it with @code{va_arg (@var{ap}, int)}.
421 The type @code{va_list} is used for argument pointer variables.
440 The @code{va_arg} macro returns the value of the next optional argument,
442 Thus, successive uses of @code{va_arg} return successive optional
445 The type of the value returned by @code{va_arg} is @var{type} as
447 @code{char} or @code{short int} or @code{float}) that matches the type
455 This ends the use of @var{ap}. After a @code{va_end} call, further
456 @code{va_arg} calls with the same @var{ap} may not work. You should invoke
457 @code{va_end} before returning from the function in which @code{va_start}
460 In @theglibc{}, @code{va_end} does nothing, and you need not ever
468 argument. But @code{va_list} is an opaque type and one cannot necessarily
469 assign the value of one variable of type @code{va_list} to another variable
477 The @code{va_copy} macro allows copying of objects of type
478 @code{va_list} even if this is not an integral type. The argument pointer
482 @code{va_copy} was added in ISO C99. When building for strict
484 GCC provides @code{__va_copy}, as an extension, in any standards mode;
491 If you want to use @code{va_copy} and be portable to pre-C99 systems,
494 simple assignment is invalid, hopefully @code{va_copy} @emph{will} be available,
531 You can assign it to any pointer variable since it has type @code{void
533 @code{NULL}.
540 You can also use @code{0} or @code{(void *)0} as a null pointer
541 constant, but using @code{NULL} is cleaner because it makes the purpose
557 data type of the result of @code{sizeof} also varies between compilers.
566 pointers. For example, with the declaration @code{char *p1, *p2;}, the
567 expression @code{p2 - p1} is of type @code{ptrdiff_t}. This will
568 probably be one of the standard signed integer types (@w{@code{short
569 int}}, @code{int} or @w{@code{long int}}), but might be a nonstandard
576 The result of the @code{sizeof} operator is of this type, and functions
577 such as @code{malloc} (@pxref{Unconstrained Allocation}) and
578 @code{memcpy} (@pxref{Copying Strings and Arrays}) accept arguments of
580 will be @w{@code{unsigned int}} or @w{@code{unsigned long int}}.
582 @strong{Usage Note:} @code{size_t} is the preferred way to declare any
587 @w{ISO C} generally used @code{unsigned int} for representing object sizes
588 and @code{int} for pointer subtraction results. They did not
589 necessarily define either @code{size_t} or @code{ptrdiff_t}. Unix
590 systems did define @code{size_t}, in @file{sys/types.h}, but the
620 can be used in @code{#if} preprocessor directives, whereas
621 @code{sizeof} cannot. The following macros are defined in
624 @vtable @code
637 These are the widths of the types @code{char}, @code{signed char},
638 @code{unsigned char}, @code{short int}, @code{unsigned short int},
639 @code{int}, @code{unsigned int}, @code{long int}, @code{unsigned long
640 int}, @code{long long int} and @code{unsigned long long int},
648 @vtable @code
657 These are the widths of the types @code{intptr_t}, @code{uintptr_t},
658 @code{ptrdiff_t}, @code{sig_atomic_t}, @code{size_t}, @code{wchar_t}
659 and @code{wint_t}, respectively.
663 integer type is for using an array of @code{unsigned long int} as a
670 Before @code{ULONG_WIDTH} was a part of the C language,
671 @code{CHAR_BIT} was used to compute the number of bits in an integer
676 This is the number of bits in a @code{char}. POSIX.1-2001 requires
689 than @code{_Bool} do not have any padding bits.
712 @samp{MAX} and @samp{MIN} macros for @code{char} and @w{@code{short
713 int}} types have values of type @code{int}. The @samp{MAX} and
715 described by the macro---thus, @code{ULONG_MAX} has type
716 @w{@code{unsigned long int}}.
719 @vtable @code
723 This is the minimum value that can be represented by a @w{@code{signed char}}.
730 @w{@code{signed char}} and @w{@code{unsigned char}}, respectively.
735 This is the minimum value that can be represented by a @code{char}.
736 It's equal to @code{SCHAR_MIN} if @code{char} is signed, or zero
742 This is the maximum value that can be represented by a @code{char}.
743 It's equal to @code{SCHAR_MAX} if @code{char} is signed, or
744 @code{UCHAR_MAX} otherwise.
749 This is the minimum value that can be represented by a @w{@code{signed
751 @code{short} integers are 16-bit quantities.
758 @w{@code{signed short int}} and @w{@code{unsigned short int}},
764 This is the minimum value that can be represented by a @w{@code{signed
765 int}}. On most machines that @theglibc{} runs on, an @code{int} is
773 the type @w{@code{signed int}} and the type @w{@code{unsigned int}}.
778 This is the minimum value that can be represented by a @w{@code{signed
779 long int}}. On most machines that @theglibc{} runs on, @code{long}
780 integers are 32-bit quantities, the same size as @code{int}.
787 @w{@code{signed long int}} and @code{unsigned long int}, respectively.
792 This is the minimum value that can be represented by a @w{@code{signed
794 @w{@code{long long}} integers are 64-bit quantities.
800 These are the maximum values that can be represented by a @code{signed
801 long long int} and @code{unsigned long long int}, respectively.
807 These are obsolete names for @code{LLONG_MIN}, @code{LLONG_MAX}, and
808 @code{ULLONG_MAX}. They are only available if @code{_GNU_SOURCE} is
815 This is the maximum value that can be represented by a @code{wchar_t}.
862 example, the number @code{123456.0} could be expressed in exponential
863 notation as @code{1.23456e+05}, a shorthand notation indicating that the
864 mantissa @code{1.23456} is multiplied by the base @code{10} raised to
865 power @code{5}.
873 The @dfn{sign} is either @code{-1} or @code{1}.
879 than @code{1}. This is a constant for a particular representation.
921 value of the fraction is always strictly less than @code{1}. The
927 fraction is at least @code{1/@var{b}}, where @var{b} is the base. In
933 If the number is not normalized, then you can subtract @code{1} from the
942 it is impossible to subtract @code{1} from the exponent, so a number
943 may be normalized even if its fraction is less than @code{1/@var{b}}.)
952 Macro names starting with @samp{FLT_} refer to the @code{float} type,
953 while names beginning with @samp{DBL_} refer to the @code{double} type
954 and names beginning with @samp{LDBL_} refer to the @code{long double}
955 type. (If GCC does not support @code{long double} as a distinct data
957 are equal to the corresponding constants for the @code{double} type.)
959 Of these macros, only @code{FLT_RADIX} is guaranteed to be a constant
971 @vtable @code
979 @table @code
996 On most machines, the value is @code{1}, in accordance with the IEEE
1000 of @code{FLT_ROUNDS}, if the other aspects of the representation match
1020 This is the number of base-@code{FLT_RADIX} digits in the floating point
1021 mantissa for the @code{float} data type. The following expression
1022 yields @code{1.0} (even though mathematically it should not) due to the
1032 where @code{radix} appears @code{FLT_MANT_DIG} times.
1037 This is the number of base-@code{FLT_RADIX} digits in the floating point
1038 mantissa for the data types @code{double} and @code{long double},
1045 This is the number of decimal digits of precision for the @code{float}
1053 The value of this macro is supposed to be at least @code{6}, to satisfy
1060 These are similar to @code{FLT_DIG}, but for the data types
1061 @code{double} and @code{long double}, respectively. The values of these
1062 macros are supposed to be at least @code{10}.
1066 This is the smallest possible exponent value for type @code{float}.
1068 @code{FLT_RADIX} raised to this power minus 1 can be represented as a
1069 normalized floating point number of type @code{float}.
1075 These are similar to @code{FLT_MIN_EXP}, but for the data types
1076 @code{double} and @code{long double}, respectively.
1080 This is the minimum negative integer such that @code{10} raised to this
1082 of type @code{float}. This is supposed to be @code{-37} or even less.
1087 These are similar to @code{FLT_MIN_10_EXP}, but for the data types
1088 @code{double} and @code{long double}, respectively.
1092 This is the largest possible exponent value for type @code{float}. More
1094 @code{FLT_RADIX} raised to this power minus 1 can be represented as a
1095 floating point number of type @code{float}.
1100 These are similar to @code{FLT_MAX_EXP}, but for the data types
1101 @code{double} and @code{long double}, respectively.
1105 This is the maximum positive integer such that @code{10} raised to this
1107 of type @code{float}. This is supposed to be at least @code{37}.
1112 These are similar to @code{FLT_MAX_10_EXP}, but for the data types
1113 @code{double} and @code{long double}, respectively.
1119 @code{float}. It is supposed to be at least @code{1E+37}. The value
1120 has type @code{float}.
1122 The smallest representable number is @code{- FLT_MAX}.
1128 These are similar to @code{FLT_MAX}, but for the data types
1129 @code{double} and @code{long double}, respectively. The type of the
1136 point number that is representable in type @code{float}. It is supposed
1137 to be no more than @code{1E-37}.
1143 These are similar to @code{FLT_MIN}, but for the data types
1144 @code{double} and @code{long double}, respectively. The type of the
1151 number of type @code{float} that is greater than 1. It's supposed to
1152 be no greater than @code{1E-5}.
1158 These are similar to @code{FLT_EPSILON}, but for the data types
1159 @code{double} and @code{long double}, respectively. The type of the
1161 supposed to be greater than @code{1E-9}.
1181 @code{float} data type, appropriate values for the corresponding
1197 Here are the values for the @code{double} data type:
1214 You can use @code{offsetof} to measure the location within a structure
1223 For example, @code{offsetof (struct s, elem)} is the offset, in bytes,
1224 of the member @code{elem} in a @code{struct s}.