В какой библиотеке содержится uint32 t
Перейти к содержимому

В какой библиотеке содержится uint32 t

'uint32_t' identifier not found error

I’m porting code from Linux C to Visual C++ for windows.

Visual C++ doesn’t know #include <stdint.h> so I commented it out.

Later, I found a lot of those ‘uint32_t’: identifier not found errors. How can it be solved?

7 Answers 7

This type is defined in the C header <stdint.h> which is part of the C++11 standard but not standard in C++03. According to the Wikipedia page on the header, it hasn’t shipped with Visual Studio until VS2010.

In the meantime, you could probably fake up your own version of the header by adding typedef s that map Microsoft’s custom integer types to the types expected by C. For example:

Fixed width integer types (since C++11)

The implementation may define typedef names intN_t , int_fastN_t , int_leastN_t , uintN_t , uint_fastN_t , and uint_leastN_t when N is not 8, 16, 32 or 64. Typedef names of the form intN_t may only be defined if the implementation supports an integer type of that width with no padding. Thus, uint24_t denotes an unsigned integer type with a width of exactly 24 bits.

Each of the macros listed in below is defined if and only if the implementation defines the corresponding typedef name. The macros INTN_C and UINTN_C correspond to the typedef names int_leastN_t and uint_leastN_t , respectively.

[edit] Macro constants

Signed integers : minimum value
Signed integers : maximum value
Unsigned integers : maximum value

[edit] Function macros for minimum-width integer constants

[edit] Format macro constants

[edit] Format constants for the std::fprintf family of functions

Each of the PRI macros listed here is defined if and only if the implementation defines the corresponding typedef name.

[edit] Format constants for the std::fscanf family of functions

Each of the SCN macros listed in here is defined if and only if the implementation defines the corresponding typedef name and has a suitable std::fscanf length modifier for the type.

[edit] Notes

Because C++ interprets a character immediately following a string literal as a user-defined string literal, C code such as printf ( "%" PRId64 " \n " ,n ) ; is invalid C++ and requires a space before PRId64 .

The C99 standard suggests that C++ implementations should not define the above limit, constant, or format macros unless the macros __STDC_LIMIT_MACROS , __STDC_CONSTANT_MACROS or __STDC_FORMAT_MACROS (respectively) are defined before including the relevant C header ( stdint.h or inttypes.h ). This recommendation was not adopted by any C++ standard and was removed in C11. However, some implementations (such as glibc 2.17) try to apply this rule, and it may be necessary to define the __STDC macros; C++ compilers may try to work around this by automatically defining them in some circumstances.

[edit] Example

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

<cstdint> (stdint.h)

The following are typedefs of fundamental integral types or extended integral types.

signed type unsigned type description
intmax_t uintmax_t Integer type with the maximum width supported.
int8_t uint8_t Integer type with a width of exactly 8, 16, 32, or 64 bits.
For signed types, negative values are represented using 2’s complement.
No padding bits.
Optional: These typedefs are not defined if no types with such characteristics exist.*
int16_t uint16_t
int32_t uint32_t
int64_t uint64_t
int_least8_t uint_least8_t Integer type with a minimum of 8, 16, 32, or 64 bits.
No other integer type exists with lesser size and at least the specified width.
int_least16_t uint_least16_t
int_least32_t uint_least32_t
int_least64_t uint_least64_t
int_fast8_t uint_fast8_t Integer type with a minimum of 8, 16, 32, or 64 bits.
At least as fast as any other integer type with at least the specified width.
int_fast16_t uint_fast16_t
int_fast32_t uint_fast32_t
int_fast64_t uint_fast64_t
intptr_t uintptr_t Integer type capable of holding a value converted from a void pointer and then be converted back to that type with a value that compares equal to the original pointer.
Optional: These typedefs may not be defined in some library implementations.*

Some of these typedefs may denote the same types. Therefore, function overloads should not rely on these being different.

* Notice that some types are optional (and thus, with no portability guarantees). A particular library implementation may also define additional types with other widths supported by its system. In any case, if either the signed or the unsigned version is defined, both the signed and unsigned versions are defined.

Macros

Limits of cstdint types
Macro description defined as
INTMAX_MIN Minimum value of intmax_t -(2 63 -1), or lower
INTMAX_MAX Maximum value of intmax_t 2 63 -1, or higher
UINTMAX_MAX Maximum value of uintmax_t 2 64 -1, or higher
INT N _MIN Minimum value of exact-width signed type Exactly -2 (N-1)
INT N _MAX Maximum value of exact-width signed type Exactly 2 (N-1) -1
UINT N _MAX Maximum value of exact-width unsigned type Exactly 2 N -1
INT_LEAST N _MIN Minimum value of minimum-width signed type -(2 (N-1) -1), or lower
INT_LEAST N _MAX Maximum value of minimum-width signed type 2 (N-1) -1, or higher
UINT_LEAST N _MAX Maximum value of minimum-width unsigned type 2 N -1, or higher
INT_FAST N _MIN Minimum value of fastest minimum-width signed type -(2 (N-1) -1), or lower
INT_FAST N _MAX Maximum value of fastest minimum-width signed type 2 (N-1) -1, or higher
UINT_FAST N _MAX Maximum value of fastest minimum-width unsigned type 2 N -1, or higher
INTPTR_MIN Minimum value of intptr_t -(2 15 -1), or lower
INTPTR_MAX Maximum value of intptr_t 2 15 -1, or higher
UINTPTR_MAX Maximum value of uintptr_t 2 16 -1, or higher

Where N is one in 8, 16, 32, 64, or any other type width supported by the library.

Only the macros corresponding to types supported by the library are defined.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *