Chapter 19: The .NET Managed Extensions to C

The <stdint.h> Header

The C99 header <stdint.h> does not declare any functions, but it does define a large number of integer types and macros. The integer types are used to declare integers of known sizes or that manifest a specified trait.

Macros of the form intN_t specify an integer with N bits. For example, int16_t specifies a 16-bit signed integer. Macros of the form uintN_t specify an unsigned integer with N bits. For example, uint32_t specifies a 32-bit unsigned integer. Macros with the values 8, 16, 32, and 64 for N will be available in all environments that offer integers in these widths.

Macros of the form int_leastN_t specify an integer with at least N bits. Macros of the form uint_leastN_t specify an unsigned integer with at least N bits. Macros with the values 8, 16, 32, and 64 for N will be available in all environments. For example, int_least16_t is a valid type.

Macros of the form int_fastN_t specify the fastest integer type that has at least N bits. Macros of the form uint_fastN_t specify the fastest unsigned integer type that has at least N bits. Macros with the values 8, 16, 32, and 64 for N will be available in all environments. For example, int_fast32_t is valid in all settings.

The type intmax_t specifies a maximum-sized signed integer and the type uintmax_t specifies a maximum-sized unsigned integer.

Also defined are the intptr_t and uintptr_t types. These can be used to create integers that can hold pointers. These types are optional.

<stdint.h> defines several function-like macros that expand into constants of a specified integer type. These macros have the following general forms:

       INTN_C(value)
       UINTN_C(value)

where N is the bit width of the desired type. Each macro creates a constant that has at least N bits that contains the specified value.

Also defined are the following macros:

       INTMAX_C(value)
       UINTMAX_C(value)

These create maximum-width constants of the specified value.




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net